Links in <select> dropdown options

Sebastian picture Sebastian · Sep 5, 2012 · Viewed 163.7k times · Source

Is it possible for each dropdown options to link somewhere when selected without the need for an external button?

<select>
  <option value="x">x</option>
  <option value="y">y</option>
</select>

Answer

Kevin picture Kevin · Sep 5, 2012

You can use the onChange property. Something like:

<select onChange="window.location.href=this.value">
    <option value="www.google.com">A</option>
    <option value="www.aol.com">B</option>
</select>