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!

Using pull-down menus for navigation

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi, I'm a begginner I am struggling with the following.
I am trying to use the below code to navigate within my site. However when I replace the url for the external links with relative urls from my site eg. "main.htm" I get an error

<SCRIPT>
<!--
function redirect(pulldown) {
newlocation = pulldown[pulldown.selectedIndex].value;
if (newlocation != &quot;&quot;)
self.location = newlocation;
}

function resetIfBlank(pulldown){
possiblenewlocation = pulldown[pulldown.selectedIndex].value;
if (possiblenewlocation == &quot;&quot;)
pulldown.selectedIndex = 0; /* reset to start since no movement */
}
//-->
</SCRIPT>
</HEAD>

<BODY>
<FORM NAME=&quot;navForm&quot;>
<B>Favorite Sites:</B>
<SELECT NAME=&quot;menu&quot; onChange=&quot;resetIfBlank(this)&quot;>
<OPTION VALUE=&quot;&quot; CLASS=&quot;nochoice&quot; SELECTED> Choose your site
<OPTION VALUE=&quot;&quot; CLASS=&quot;nochoice&quot;>
<OPTION VALUE=&quot;&quot; CLASS=&quot;nochoice&quot;>Search Sites
<OPTION VALUE=&quot;&quot; CLASS=&quot;nochoice&quot;>------------
<OPTION VALUE=&quot; CLASS=&quot;choice&quot;>Yahoo!
<OPTION VALUE=&quot; CLASS=&quot;choice&quot;>HotBot
<OPTION VALUE=&quot; CLASS=&quot;choice&quot;>Google
<OPTION VALUE=&quot;&quot; CLASS=&quot;nochoice&quot;>
<OPTION VALUE=&quot;&quot; CLASS=&quot;nochoice&quot;>E-commerce
<OPTION VALUE=&quot;&quot; CLASS=&quot;nochoice&quot;>------------
<OPTION VALUE=&quot; CLASS=&quot;choice&quot;>Amazon
<OPTION VALUE=&quot; CLASS=&quot;choice&quot;>Buy.com
<OPTION VALUE=&quot;&quot; CLASS=&quot;nochoice&quot; CLASS=&quot;choice&quot;>
<OPTION VALUE=&quot;&quot; CLASS=&quot;nochoice&quot;>Demos
<OPTION VALUE=&quot;&quot; CLASS=&quot;nochoice&quot;>------------
<OPTION VALUE=&quot; CLASS=&quot;choice&quot;>DemoCompany
</SELECT>
<INPUT TYPE=&quot;button&quot; VALUE=&quot;go&quot;
onClick=&quot;redirect(document.navForm.menu)&quot;>
</FORM>
<SCRIPT>
<!--
document.navForm.menu.selectedIndex = 0;
//-->
</SCRIPT>
 
hi !
i just copied/pasted your code (obviously, put in the <html><head> and their respective closing tags etc..
and ran the code -

WORKED FINE !!!

choose a location from the menu (ie, Yahoo), and voila - yahoo opens in a new window.. :)
 
using location works much better if you use a complete URL. Even for pages within your own site you can still code a complete URL. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top