Rachid O
Rachid O

Reputation: 14002

Inserting a link inside a select tag?

How can i change the page when someone clicks an option inside the select tag ?

<select>
  <option><a href="/1" >1</a></option>
  <option><a href="/2" >2</a></option>
  <option><a href="/3" >3</a></option>
</select>

Upvotes: 0

Views: 75

Answers (2)

Guffa
Guffa

Reputation: 700342

Use the onchange event:

<select onchange="window.location.href=this.options[this.selectedIndex].value">

Upvotes: 0

शेखर
शेखर

Reputation: 17614

You can use ONCHANGE event of java-script as follow

<select name="forma" ONCHANGE="location = this.options[this.selectedIndex].value;">
    <option value="Home.php">Home</option>
    <option value="Contact.php">Contact</option>
</select>

In your case

<select onchange="location = this.options[this.selectedIndex].value;">
  <option value=="/1" >1</a></option>
  <option value=="/2" >2</a></option>
  <option value="/3" >3</a></option>
</select>

Upvotes: 2

Related Questions