Forum Moderators: open
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
- 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.