Forum Moderators: open

Message Too Old, No Replies

Jump Menu - Keep Value When Switched

Keep Value When Switching Drop Down Option

         

syktek

9:59 pm on Sep 28, 2006 (gmt 0)

10+ Year Member



Hi,

I have created a jump menu and I was wondering if it was possible that when the jump menu reloads the page with the new query that the value selected from the drop down shows as the default selected?


<select name="switchPrice" id="seacPrice" onchange="location.href=this.value;">
<option value="javascript:;">Sort by Price</option>
<option value="http://www.mysite.com/search.html&setsortorder=price,name&setsortprice=descending&setpagenum=1">Highest to Lowest</option>
<option value="http://www.mysite.com/search.html&setsortorder=price,name&setsortprice=ascending&setpagenum=1">Lowest to Highest</option>
</select>
<select name="switchName" id="seacPrice" onchange="location.href=this.value;">
<option value="javascript:;">Sort by Name</option>
<option value="http://www.mysite.com/search.html&setsortorder=name&setsortname=ascending&setpagenum=1&setsortprice=">A to Z</option>
<option value="http://www.mysite.com/search.html&setsortorder=name&setsortname=descending&setpagenum=1&setsortprice=">Z to A</option>
</select>

So if someone sorts by name a-z, when the page reloads i want a-z to be the selected value.

Thanks

DrDoc

5:06 am on Sep 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It is possible if you either:

- Generate the dropdown itself using JavaScript
- Generate the dropdown itself via some server side script

Technically, you could set the selectedIndex for your dropdown once it has loaded, but that would trigger the onchange event as well, so that won't work in this case.

penders

11:42 am on Oct 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Technically, you could set the selectedIndex for your dropdown once it has loaded, but that would trigger the onchange event as well, so that won't work in this case.

Could you not assign the onchange event after you had set the selectedIndex property - to avoid it being triggered prematurely?