Drop down link to new page

M

mark s.

I want to link to another page based on the user
selecting a value in the drop-down box. Simple right?

Mark
 
S

Steve Easton

Actually it's fairly simple using some javascript. Here's an example. Copy and paste it into a new
blank page and play with it.

<p align="center"><b>Select a Site:</b><select id="setit">
<option value="">Select one</option>
<option value="javascript:window.open('http://www.altavista.com')">AltaVista</option>
<option value="javascript:window.open('http://www.yahoo.com')">Yahoo</option>
<option value="javascript:window.open('http://www.google.com')">Google</option>
</select><input type="button" value="Go" onclick="launchit()"></input>

<script language="javascript">
function launchit(){
eval(setit.options[setit.selectedIndex].value);
}
</script>


Notice it has a "Go" button for people who can't use a mouse.

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
S

Steve Easton

Also this one will work and doesn't need the external script tags containing the function:

<p align="center"><b>Select a Site or Function: </b><select id="setit">
<option value="">Select one</option>
<option value="javascript:window.open('http://www.altavista.com')">AltaVista</option>
<option value="javascript:window.open('http://www.google.com')">Google</option>
</select><input type="button" value="Go"
onclick="eval(setit.options[setit.selectedIndex].value)"></input>



--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
S

Steve Easton

Yes. However, the drawback is that people with disabilities which prevent them from using a mouse
will never be able to select anything other than the first item in the list.
That's why I didn't post it that way. However, here it is.

<p align="center"><b>Select a Site: </b><select id="setit"
onchange="eval(setit.options[setit.selectedIndex].value)">
<option value="">Select one</option>
<option value="javascript:window.open('http://www.altavista.com')">AltaVista</option>
<option value="javascript:window.open('http://www.yahoo.com')">Yahoo</option>
<option value="javascript:window.open('http://www.google.com')">Google</option>
</select>


--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer

RC- said:
Steve,
Your code sample will work for what I'm trying to do too! I have one
question though, I want to fire the event on the onChange trigger. It works
if I actually change from one value to another, but I want to be able to
fire it just by clicking on the value. The onClick trigger fires before I
have made my selection. Is there way I can do this?

TIA
RC-

Steve Easton said:
Also this one will work and doesn't need the external script tags containing the function:

<p align="center"><b>Select a Site or Function: </b><select id="setit">
<option value="">Select one</option>
<option value="javascript:window.open('http://www.altavista.com')">AltaVista</option

<option
value="javascript:window.open('http://www.google.com')">Google said:
</select><input type="button" value="Go"
onclick="eval(setit.options[setit.selectedIndex].value)"></input>



--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
.......................with a computer

mark s. said:
I want to link to another page based on the user
selecting a value in the drop-down box. Simple right?

Mark
 
S

Steve Easton

Correct. That's how it is supposed to work. Go back and select a different entry and it will open
a different page.
I don't understand why you need to go back, and then reselect the same page to open again.!! ??


--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer

RC- said:
The onchage trigger still does not do what I need it to. For example, I
click the drop down and choose Alta Vista. I am then directed to the Alta
Vista site. I go back and click the drop down and choose Alta Vista again
and nothing happens, because the onchage event was not triggered because
nothing changed.



Steve Easton said:
Yes. However, the drawback is that people with disabilities which prevent them from using a mouse
will never be able to select anything other than the first item in the list.
That's why I didn't post it that way. However, here it is.

<p align="center"><b>Select a Site: </b><select id="setit"
onchange="eval(setit.options[setit.selectedIndex].value)">
<option value="">Select one</option>
<option value="javascript:window.open('http://www.altavista.com')">AltaVista</option

<option
value="javascript:window.open('http://www.yahoo.com')">Yahoo said:
value="javascript:window.open('http://www.google.com')">Google said:
</select>


--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
.......................with a computer

Steve,
Your code sample will work for what I'm trying to do too! I have one
question though, I want to fire the event on the onChange trigger. It works
if I actually change from one value to another, but I want to be able to
fire it just by clicking on the value. The onClick trigger fires before I
have made my selection. Is there way I can do this?

TIA
RC-

Also this one will work and doesn't need the external script tags
containing the function:

<p align="center"><b>Select a Site or Function: </b><select id="setit">
<option value="">Select one</option>
<option
value="javascript:window.open('http://www.altavista.com')">AltaVista</option

<option
value="javascript:window.open('http://www.google.com')">Google</option>
</select><input type="button" value="Go"
onclick="eval(setit.options[setit.selectedIndex].value)"></input>



--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
.......................with a computer

I want to link to another page based on the user
selecting a value in the drop-down box. Simple right?

Mark
 
S

Steve Easton

Ah Ok.

The problem is that onclick, onselect and onchange are all mouse ( or keyboard ) "events" and until
the user creates a "new" event with some definite action they won't "fire" If they would, as soon
as you went back to the page it would automatically reopen Google or what ever had been previously
selected.

I do recommend the Go button version though.

;-)

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer

RC- said:
You open Google, run your search and then close the google page w/o giving
it a second though. Now, you want to lauch Google again but you can't
launch it by clicking on the Google option in the drop down so you have to
click somthing else just to get it to run again. Probably won't happen
often, but I'm sure it will ;-).

But, I decided to just go with the original design of having a go button,
it's better in the long run!

Thanks for your input!

Steve Easton said:
Correct. That's how it is supposed to work. Go back and select a
different entry and it will open
a different page.
I don't understand why you need to go back, and then reselect the same page to open again.!! ??


--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
.......................with a computer

The onchage trigger still does not do what I need it to. For example, I
click the drop down and choose Alta Vista. I am then directed to the Alta
Vista site. I go back and click the drop down and choose Alta Vista again
and nothing happens, because the onchage event was not triggered because
nothing changed.



Yes. However, the drawback is that people with disabilities which prevent
them from using a mouse
will never be able to select anything other than the first item in the
list.
That's why I didn't post it that way. However, here it is.

<p align="center"><b>Select a Site: </b><select id="setit"
onchange="eval(setit.options[setit.selectedIndex].value)">
<option value="">Select one</option>
<option
value="javascript:window.open('http://www.altavista.com')">AltaVista</option

<option
value="javascript:window.open('http://www.yahoo.com')">Yahoo</option>
<option
value="javascript:window.open('http://www.google.com')">Google</option>
</select>


--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
.......................with a computer

Steve,
Your code sample will work for what I'm trying to do too! I have
one
question though, I want to fire the event on the onChange trigger. It
works
if I actually change from one value to another, but I want to be able to
fire it just by clicking on the value. The onClick trigger fires before
I
have made my selection. Is there way I can do this?

TIA
RC-

Also this one will work and doesn't need the external script tags
containing the function:

<p align="center"><b>Select a Site or Function: </b><select
id="setit">
<option value="">Select one</option>
<option

value="javascript:window.open('http://www.altavista.com')">AltaVista</option

<option
value="javascript:window.open('http://www.google.com')">Google said:
</select><input type="button" value="Go"
onclick="eval(setit.options[setit.selectedIndex].value)"></input>



--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
.......................with a computer

I want to link to another page based on the user
selecting a value in the drop-down box. Simple right?

Mark
 
Top