How to create a dropdown hyperlink without a GO button?

I just want to create a drop-down list when I select a new value inside it and this will lead me to a new web page. I don’t want the user to click the GO button to go to the page. Just select and trigger an action. How can i do this?

<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 a GO button and you will need to click GO to go to a new page. I do not want the GO button.

Any ideas?

+5
source share
3 answers

use the onchange event:

<select onchange="window.open(this.value,'','');">
....
</select>
+16
source

As I understand it, you just need to handle the onchange event for the selected tag. Just move the onclick handler.

0
source

onclick

<input type="button" value="Go "onclick="document.location = this.value">

(All the other stitches that let you exchange and say don't use javascript, but if the browser that the person uses does not support javascript, then hard shit because chrome or another leading browser is not used)

0
source

All Articles