Combined Menu

[Total: 0    Average: 0/5]

Sends the user to a specific URL based on the combined selections from two different pulldown menus.

Head Code:

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
site = "http://www.js-examples.com"; // Do not include the final "/"
function combineMenus(frm, menu1, menu2) {
with (frm) {
str = menu1.options[menu1.selectedIndex].value;
str += menu2.options[menu2.selectedIndex].value;
url = site + "/" + str + ".html";
alert("New page would be: "+url);
// uncomment this next line to make it work (and comment the alert)
//window.location.href = url;
   }
}
//  End -->
</script>

Body Code:

<center>
<form name=menufrm>
<select name=menu1>
<option value="">Menu1</option>
<option value="one">One</option>
<option value="two">Two</option>
<option value="three">Three</option>
</select>

<select name=menu2>
<option value="">Menu2</option>
<option value="four">Four</option>
<option value="five">Five</option>
<option value="six">Six</option>
</select>

<input type=button value="Select" onClick="combineMenus(this.form, this.form.menu1, this.form.menu2)">
</form>
</center>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *