JavaScript
Drop Down List
Back


Drop Down Lists are used to display multiple choices in a small amount of space.

Example:

A form with a drop down list and button

Replace type between the quotes after OPTION VALUE to your URL. Replace the YOUR DISCRIPTION type with a suitable discription.

Add more OPTION tags to add more selections.

FRAMES - To open a selection in a document that uses frames you need to specify the frame name to open the selection in. Change the top.location.href in the GotoURL function to: parent.putyourframenamehere.location.href.

Code:

<FORM NAME="URLlist">
<SELECT NAME="droplist">
<OPTION SELECTED="SELECTED" VALUE=" ">Select a Destination!</OPTION>
<OPTION VALUE="http://www.yoururl.com">Your Discription</OPTION>
<OPTION VALUE="http://www.yoururl1.com">Your Discription1</OPTION>
<OPTION VALUE="http://www.yoururl2com">Your Discription2</OPTION>
</SELECT><INPUT TYPE="BUTTON" VALUE="Go!" ONCLICK="GotoURL(this.form)">
<SCRIPT LANGUAGE="JavaScript"> 
<!--
function GotoURL(dl) { 
// FRAMES - To open a selection in a document that uses frames 
// change top.location.href to parent.putyourframenamehere.location.href
top.location.href = dl.droplist.options[dl.droplist.selectedIndex].value;
} 
// -->
</SCRIPT>
</FORM>


Rate this script
Excellent Acceptable Poor
Comment: