<select> list of hyperlinks: onchange="location=this.options[this.selectedIndex].value" or onchange="location=this.value"
17,658
I think the second method will work fine on most browsers but you need the first method if you're using IE.
Author by
Haradzieniec
Updated on June 05, 2022Comments
-
Haradzieniec about 2 years
<select onchange="location = this.options[this.selectedIndex].value;"> <option value="myhome.html">My Home Page</option> <option value="myresume.html">Resume</option> <option value="myhobbies.html">Hobbies</option> <option value="mydog.html">My Dog</option> </select> <select onchange="location = this.value;"> <option value="myhome.html">My Home Page</option> <option value="myresume.html">Resume</option> <option value="myhobbies.html">Hobbies</option> <option value="mydog.html">My Dog</option> </select>
The first method is taken from http://www.faqs.org/docs/htmltut/forms/_SELECT_onChange.html, but the second method (which I've used) works fine. Is the second method incorrect?
Thank you.