PDA

View Full Version : Select menu - dynamically jump to an <option> item



mtran
09-22-2008, 03:35 PM
Hi,

I have 2 pages with details as follow:



PAGE 1: a pulldown Select menu with a couple of items and an
onchange event which will show and hide content [on the same page]
depending on user's selection

<!--Pulldown -->
<select name="drop1" onchange="hideAll_TouchOs();
showTouchOs(this.options[selectedIndex].value);">
<option selected>Select Your Operating System</option>
<option value="WVista">Windows Vista</option>
<option value="WVista64">Windows Vista (64-bit)</option>
<option value="WXP">Windows XP</option>
<option value="W2000">Windows 2000</option>
</select>

<!--Content to be shown or hidden-->
........ Blah blah ...........

PAGE 2: the same pulldown and no other content. When people
select from here, the pulldown will take them to PAGE 1 and show the
correct content on PAGE 1. I did this through passing some parameters in the url.

<!--The same Pulldown -->
<select name="drop1" onchange="hideAll_TouchOs();
showTouchOs(this.options[selectedIndex].value);">
<option selected>Select Your Operating System</option>
<option value="WVista">Windows Vista</option>
<option value="WVista64">Windows Vista (64-bit)</option>
<option value="WXP">Windows XP</option>
<option value="W2000">Windows 2000</option>
</select>



Everything works out ok, except: if people select e.g. Windows XP on PAGE 2, Windows XP content shows on PAGE 1, but the pulldown itself still starts with "Select your Operating Systems."

Is there a way to make the pulldown to jump to "Window XP" instead of "Select your Operating Systems"?

Thanks for your input!

jscheuer1
09-22-2008, 08:37 PM
That sort of functionality (saving and reporting back on previous form element choices) is generally the province of server side code like asp or PHP, not client side code like javascript. However, javascript can be used to detect the user's OS and many other things, so actually asking them to choose is unnecessary, unless their browser is (as some can) spoofing another OS.