How To Create Custom Select Menus with link to URL

533 views Asked by At

I have this code: https://www.w3schools.com/howto/howto_custom_select.asp

I just want to add a different URL to each option so it gets opened when clicked. I've tried so many ways and none of them works. I don't understand Javascript and I think the options I've tried may be in conflict with this ones.

Can anyone help with this issue? Thank you so much for your time and help.

2

There are 2 answers

5
Caleb On

Try "onclick" instead of "value".

<option onclick="window.location='http://www.google.com'">Google</option>
1
Caleb On

You have to add value and onchange to option for example:

<select onchange="window.location=this.value">
    <option value="http://www.google.com">Google</option>
    <option value="http://www.yahoo.com">Yahoo</option>
    <option value="http://www.bing.com">Bing</option>
</select>