28th November 2022

Navigation through a select tag

List the links to navigate to inside the select tag while giving the option tag a value attribute with the url.

<select>
  <option value="https://www.google.com">Link 1</option>
  <option value="https://www.google.com">Link 2</option>
  <option value="https://www.google.com">Link 3</option>
</select>

Then, finally in order for it to work we would like the browser to navigate to the chosen link when the value of the Select tag changes.

This is how to do it using the onchange attribute;

<select onchange="window.open(this.value,'_self');">
  <option value="https://www.google.com">Link 1</option>
  <option value="https://www.google.com">Link 2</option>
  <option value="https://www.google.com">Link 3</option>
</select>