Lesson 14 - Javascript Pulldown Menu for Redirection
Homepage
Sporting Goods :
Baseball:
- Gloves
- Bats and Balls
Surfing:
- Boards
- Wet Suits
Tennis:
- Racquets
- Shoes
- Strings and Grips
Contact Us
Script
function menuAction(sel)
{ var index = sel.selectedIndex;
var url = sel.options[index].value;
sel.selectedIndex = 0;
if ( url != -1)
{ alert("page to load: " + url);
window.location=url;
}
}
HTML
<table cellspacing="0" width = 500 style = "text-align : center" cellpadding = 10>
<tr valign="middle" align="center" bgcolor ="lightblue">
<td rowspan="1" colspan="1">
<a href="home.html" >Homepage
</td>
<td rowspan="1" colspan="1" >
<select name="selurl" id="selurl" size="1" onchange="menuAction(this)">
<option value="-1">Sporting Goods :
<option value="-1" />
<option value="baseball/index.html">Baseball:
<option value="baseball/gloves.html"> - Gloves
<option value="baseball/bats.html"> - Bats and Balls
<option value="-1" />
<option value="surfing/index.html">Surfing:
<option value="surfing/boards.html"> - Boards
<option value="surfing/suits.html"> - Wet Suits
<option value="-1" />
<option value="tennis/index.html">Tennis:
<option value="tennis/racquets.html"> - Racquets
<option value="tennis/shoes.html"> - Shoes
<option value="tennis/misc.html"> - Strings and Grips
</select>
</td>
<td rowspan="1" colspan="1">
<a href="contact.html" shape="rect">Contact Us
</td>
</tr>
</table>