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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select and go navigation - multiple menus 1

Status
Not open for further replies.

Zhris

Programmer
Aug 5, 2008
254
GB
I am trying to use two select and go navigation menus on one page, however only the first of the two works (the second does nothing). I have even tried giving each menu a different ID then changing the javascript to incorporate this with no success. Then instead of adding to the javascript, I used two separate external javascript files, one for each menu, still with no success.

Any suggestions how I could get both menus to work on the same page?

index.htm
Code:
<HEAD>
<SCRIPT SRC="Select_And_Go_Navigation.js"></SCRIPT>
</HEAD>

<SELECT CLASS="Menu" ID="Select_And_Go_Menu">
<OPTION VALUE="#">>>>>></OPTION>
<OPTION VALUE="[URL unfurl="true"]http://www.google.com">Google</OPTION>[/URL]
<OPTION VALUE="[URL unfurl="true"]http://www.yahoo.com">Yahoo</OPTION>[/URL]
<OPTION VALUE="[URL unfurl="true"]http://www.altavista.com">Alta[/URL] Vista</OPTION>
</SELECT>

<SELECT CLASS="Menu" ID="Select_And_Go_Menu">
<OPTION VALUE="#">>>>>></OPTION>
<OPTION VALUE="[URL unfurl="true"]http://www.google.com">Google[/URL] 2</OPTION>
<OPTION VALUE="[URL unfurl="true"]http://www.yahoo.com">Yahoo[/URL] 2</OPTION>
<OPTION VALUE="[URL unfurl="true"]http://www.altavista.com">Alta[/URL] Vista 2</OPTION>
</SELECT>

Select_And_Go_Navigation.js
Code:
window.onload = initForm;
window.onunload = function() {};

function initForm() {
	document.getElementById("Select_And_Go_Menu").
	selectedIndex = 0;
	document.getElementById("Select_And_Go_Menu").
	onchange = jumpPage;
}

function jumpPage() {
	var newLoc = document.getElementById("Select_And_Go_Menu");
	var newPage = newLoc.options[newLoc.selectedIndex].value;
	if (newPage != "") {
		window.location = newPage;
	}
}

Thanks,

Chris
 
Try this
Code:
<SELECT CLASS="Menu" ID="Select_And_Go_Menu" onchange="window.location=this.value;">

That alone without your JS should do the trick.

--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
 
Thank you very much, did the trick perfectly!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top