Jump to content

Open New Window With A Select Form


bukwus

Recommended Posts

HiI'm building a drop down menu and each option link needs to open a new window. Here's the code:

<form><select onChange="if(options[selectedIndex].value) window.location.href=(options[selectedIndex].value)"><option>Select a Country</option><option value="http://www.link.com">Global</option>etc.

I'm thinking there's extra code I need to add to the onChange, but I'm not sure what that would be. Can anyone help me with this?Thanks

Link to comment
Share on other sites

You have the right idea. So far, the script is looking for variables named options and selectedIndex. These variables do not exist. They are properties of the select object. So you need a reference to the select object to access those properties. The good news is that your script is embedded in the select object itself. So you can get the reference you need just by using the this keyword. The following should work:if(this.options[this.selectedIndex].value)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...