Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: query string

  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    query string

    Goal: get query string and email the sting upon users submitting form.
    Reason: To know what marketing ad unit the user can from

    Details:
    Look for some help. I need to get a query sting from the url (ex. example.htm?id=22e&moreid=99lk) and store the stings as vars and be able to pass these vars from page to page (hidden from the user) and when the user gets to a registration form and submits the form, the vars get attached to the email that is sent to me, so I know where they came from.

    Is this idea possible and feasible in Javascript, if so can someone point me in a driection?

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,928
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    You can capture the query string as follows:-

    alert (location.href.substring(n));

    where n is a number representing the first character of the text you wish to capture, that is the one following the ?.

    You can the write this out to a cookie, the value of which is added to a hidden field in your form.

    However, the trouble with using mailto: to send form results is its unpredictability. The method it is highly dependent on the browser in use and the email client in use (some people have only Yahoo or Hotmail). In particular, some of the most popular versions of Internet Explorer/Outlook Express will not work correctly. With all of the browser troubles, you're likely to lose about half of your users' messages. Most of the email clients that can successfully send a mail will prompt the user by a security dialog prior to sending - this can scare many users from continuing. Also, what about people with Javascript disabled?

    In fact few browsers these days accept mailto: as a form action. You need a really old browser for it to work as more modern browsers simply open the email program (if any) and ignore the form. If you are going to use a form for your registration then use a server-side formmail script as the action - there are several good free ones out there.


    Haikus are easy
    But sometimes they don't make sense.
    Refrigerator.

  • #3
    New to the CF scene
    Join Date
    May 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post

    Yeah, I already have an online form that does a lot of stuff, I was just looking to capture the query string form the initial landing page, and have it carry through the visit and when/if they fill out the form the query string data would attach itself to the form via hidden values and when the form is submitted an email gets sent to me and I then I can see the query string (which was the initial landing page the landed on).

    However, you are suggesting the only way to do this with javascript is with a cookie?

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,928
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •