Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Create a Dropdown List Hyperlink without the GO button?

I just want to create a dropdown list whenever I choose a new value inside it will take me to a new webpage. I don't want to let user to click "GO" button to go to the page. Just on select and call the action. How can I do such ?

<form>
<p align="center"><b>Select a Site </b>
<select id="setit" style="color: #0000FF" size="1" name="test">
<option value="">Select one</option>
    <option value="http://www.altavista.com">AltaVista</option>
    <option value="http://www.yahoo.com">Yahoo</option>
     <option value="http://www.google.com">Google</option></select>
     <input type="button" value="Go"
onclick="window.open(setit.options[setit.selectedIndex].value)">
</p></form>

Here for example, this will have the GO button and need to click the GO in order to go to the new page. I don't want the GO button.

Any ideas?

like image 249
Jonathan Avatar asked Oct 21 '09 06:10

Jonathan


1 Answers

use onchange event:

<select onchange="window.open(this.value,'','');">
....
</select>
like image 199
jerjer Avatar answered Nov 15 '22 06:11

jerjer