[Javascript] <option> and onSelect
Peter Brunone
peter at brunone.com
Fri Mar 19 17:57:34 CST 2004
Cool! How long have we been able to refer to options and
selectedIndex as static members from inside their parent select element?
I've always thought I needed to preface them with "this." in all cases.
Peter
-----Original Message-----
From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu] On Behalf Of Paul Novitski
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