Drop-down form, when you click on an item, go to the link without clicking the submit button

I have a drop down form, and when the user clicks on the item, I want them to go to the URL that I have in the code without clicking the submit button. Here is the code that I still have

<select name="mydropdown" class="styled" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO">
<option value="http://www.cats.com">Select Your Compliance Center</option>
<option value="http://www.funcats.com">Fresh Milk</option>
<option value="http://cutecats.com">Old Cheese</option>
<option value="http://lolcats.com">Hot Bread</option>
</select>

but it does not seem to work.

Any help would be greatly appreciated.

+3
source share
2 answers

Use this:

<select name="mydropdown" class="styled" onChange="document.location = this.value" value="GO">
        <option value="http://www.cats.com">Select Your Compliance Center</option>
        <option value="http://cutecats.com">Old Cheese</option>
        <option value="http://lolcats.com">Hot Bread</option>
</select>
+11
source

More or less the same as the other answer, but this one goes through the form.

<form name="linkForm" method="POST" action="" id="form">
  <select name="mydropdown" class="styled" onchange="document.getElementById('form').setAttribute('action', this.value); document.linkForm.submit(); ">
    <option value="http://www.cats.com">Select Your Compliance Center</option>
    <option value="http://www.funcats.com">Fresh Milk</option>
    <option value="http://cutecats.com">Old Cheese</option>
    <option value="http://lolcats.com">Hot Bread</option>
  </select>
</form>
0
source

Source: https://habr.com/ru/post/1778336/


All Articles