Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select drop-down list 1

Status
Not open for further replies.

manj

Programmer
Sep 22, 2000
28
GB
I have a drop-down box with various options. The question is how do I dirct the user to the desired page when they select a particular option. Is it something to do with the onChange or onFocus event handler?

Any help appreciated.
Cheers
 
Yes, the use the onChange event handler. Here's the JavaScript code that I use with my drop-down boxes to direct the user to the appropriate page. Put this code in your HEAD section:

<script language=&quot;JavaScript&quot;>
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+&quot;.location='&quot;+selObj.options[selObj.selectedIndex].value+&quot;'&quot;);
if (restore) selObj.selectedIndex=0;
}
//-->
</script>


Here's the code for the drop-down box. This will go in the desired location in your BODY:

<form NAME=&quot;form1&quot;>
<div align=&quot;left&quot;>
<p>
<select name=&quot;menu1&quot; onChange=&quot;MM_jumpMenu('parent',this,0)&quot;>
<option value=&quot;Link1.html&quot; selected>Link1</option>
<option value=&quot;Link1.html&quot;>______________</option>
<option value=&quot;Link1.html&quot;>Link1</option>
<option value=&quot;Link2.html&quot;>Link2</option>
<option value=&quot;Link3.html&quot;>Link3</option>
</select>
</p>
</div>
</form>

Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top