|
|
<SELECT ...>
First, copy this Javascript and paste it exactly as is into the <HEAD>
<SCRIPT TYPE="text/javascript">
<!--
function dropdown(mySel)
{
var myWin, myVal;
myVal = mySel.options[mySel.selectedIndex].value;
if(myVal)
{
if(mySel.form.target)myWin = parent[mySel.form.target];
else myWin = window;
if (! myWin) return true;
myWin.location = myVal;
}
return false;
}
//-->
</SCRIPT>
Now we create a <SELECT ...>
<FORM
ACTION="../cgi-bin/redirect.pl"
METHOD=POST onSubmit="return dropdown(this.gourl)">
<SELECT NAME="gourl">
<OPTION VALUE="">Choose a Destination...
<OPTION VALUE="/tags/" >Guide to HTML
<OPTION VALUE="/" >Idocs Home Page
<OPTION VALUE="http://www.ninthwonder.com" >Ninth Wonder
</SELECT>
<INPUT TYPE=SUBMIT VALUE="Go">
</FORM>
VALUE<OPTION ...>
<OPTION VALUE="http://www.ninthwonder.com" >Ninth Wonder
indicates that the URL is
http://www.ninthwonder.com and the menu option should read
Ninth Wonder.
Notice that the first option, the one that reads "Choose a Destination...", has an empty string as its value. That empty string tells the script that the user didn't really choose a URL and it shouldn't do anything.
Here's how it all works. When the web page first comes up, the first option in the select list is displayed. The first option is a dummy which just gives the instruction to choose a page. The user selects an option and clicks on "Go". If they selected the first option nothing happens. If they choose any of the remaining options the script gets the URL from the value of the option and redirects the browser to that page. If the browser does not have Javascript (something to always plan for) then the browser goes to
../cgi-bin/redirect.pl (we've already got the CGI set up for you) which uses good old fashioned HTTP to redirect the browser.
This technique also allows you to target the list at another frame. We'll look at that next.
|
Recommended Resources |
|||
| web hosting tutorials Credit Help |
Search the Internet Search Engine Help |
Low Fat Lifestyle Internet Traffic |
Web
Hosting Web Design |
|
Discount
Hotel Reservations All
Rights Reserved, Copyright © Free-HTML-Tutorials.com 2003 |
|||