Welcome to WebmasterWorld Guest from 54.167.83.224

Forum Moderators: open

Message Too Old, No Replies

Select Control onChange Event

Difference betw. IE/Opera and Mozilla/Netscape?

     
10:03 pm on Jun 5, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:May 16, 2003
posts:592
votes: 0


Ok I am encountering a problem with my onChange event for a select control. In Mozilla and Netscape, 'this.value' gets sent properly to my function, but in IE and Opera 'this.value' is nothing.

Simplified version of code:

<select name="weeks" onChange="alert(this.value);">
<option> </option>
<option>4</option>
<option>8</option>
<option>12</option>
<option>16</option>
<option>20</option>
<option>24</option>
</select>

Any idea why this problem is occuring and what I can do to remedy it?

Thanks.

10:46 pm on June 5, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 27, 2002
posts:125
votes: 0


On the face of it, it looks like it should work.

If you change the onChange event handler to
onChange="alert(this.options[this.selectedIndex].value);"

and explictly state the options value,
<option value="4">4</option>

Then it works.

10:56 pm on June 5, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:May 16, 2003
posts:592
votes: 0


Thanks that works.

Curious as to why my original method would work properly in Mozilla but not IE.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members