Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey Guys,
So I've been trying my best to figure this out on my own, but I'm completely stuck. I have a form for users to fill out. I also have links spread throughout my site that takes them to this form. I want to populate one of the dropdowns in that form based on where they came from. My dropdown is called id="show_customer3".

HTML
    <div id="show_demo2" >
      <p>Where did you hear about us?:</p>
    </div>
<!--This is where the user selects which product they own.-->
  <td colspan="1" rowspan="1">
    <div id="show_customer3" style="display: none;">
      <p><select id="WHAT" name="WHAT" size="1">
        <option selected="selected" value="">Select One</option>
        <option value="Item 1">Item 1</option>
        <option value="Item 2">Item 2</option>
        <option value="Item 3">Item 3</option>
        <option value="Item 4">Item 4</option>
        <option value="Item 5">Item 5</option>
        <option value="Item 6">Item 6</option>
        <option value="Item 7">Item 8</option>
        <option value="Item 9">Item 9</option>
        <option value="Item 10">Item 10</option>
        <option value="Item 11">Item 11</option>
        <option value="Item 12">Item 12</option>
      </select></p>
    </div>

    <div id="show_demo3" style="display: none;">
      <p>
        <input maxlength="64" name="WHERE" size="30" type="text" value="" />
      </p>
    </div>
  </td>


I was thinking my link would look something like:
HTML
mysite.com/thispage#show_customer3;selected="Item 1"


I appreciate any help. Thanks!
Posted

1 solution

So add a parameter to the link on the other pages that denotes which page they came from. The parameter will have to get picked up by the code in this page to tell it where the user came from.

An alternate method is to look in the HTML request properties for the REFERER item. That will be the page the user just came from.
 
Share this answer
 
Comments
Member 11803895 1-Jul-15 15:00pm    
Do I add the parameter to the page that they are coming from? Or inside the link they are clicking on?

How do you look for a Referer item?

Thanks so much for your help!
Dave Kreskowiak 1-Jul-15 15:32pm    
You put it in the link on the previous page.

https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=javascript%20http%20request%20parameters

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900