[Javascript] <option> and onSelect

Paul Novitski paul at dandemutande.org
Fri Mar 19 16:15:57 CST 2004


The problem is that the event belongs to the <select> tab, not the <option> 
tag.  Try this:

<select onChange="document.location=options[selectedIndex].value;">
<option value="http://www.apple.com">Apple
<option value="http://www.banana.com">Banana
<option value="http://www.carbon.com">Carbon
</select>

Paul


At 01:53 PM 3/19/2004, you wrote:
>I can't make the following work. The idea is to change the document.location
>to the url in the
>"value" paramater of an <option> tag when the latter is selected.
>The whole thing must be written on the fly with javascript as shown below
>
>document.write("<option value='http://www.mysite.com'
>onSelect='document.location=this.value'>Site One</option>")
>
>Thanks in advance.





More information about the Javascript mailing list