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

Dropdown menu, one option linked

Status
Not open for further replies.

leonk09

Technical User
Nov 9, 2005
20
GB
Hi,

I've got a plain and simple drop-down menu.

But....I want one of the values to open a link in a target window when selected (just one, the others should be just normal values).

Is there a way to do this because currently I only have scripts for making every value a link.

Thanks for your help
 
if the values are static, you could do something like this:

Code:
function doBlah(s, i) {
    if (s.selectedIndex == i) {
        window.location = s.options[i].value;
    }
}

and then

Code:
<select onchange="doBlah(this, 2);">
  <option value="hi">hi</option>
  <option value="bye">bye</option>
  <option value="[URL unfurl="true"]http://www.google.com/">google</option>[/URL]
  <option value="stuff">stuff</option>
</select>

*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
Cooool,

thanks a bunch.

How do I get it to a target frame though?
 
you'll need to change your funtion slightly:

Code:
function doBlah(s, i) {
    if (s.selectedIndex == i) {
        top.frames['yourFrameName'].location = s.options[i].value;
    }
}

*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top