By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,636 Members | 1,189 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,636 IT Pros & Developers. It's quick & easy.

IE Bug: onchange event not called when using <optgroup> in select drop-down

P: n/a
In a <select> drop-down, the onchange event isn't called when
scrolling through the dropdown using the mouse-wheel and when crossing
over a new <optgroup>.

Using the example below, notice how the onchange event isn't called
when mouse wheel scrolling between A3 and B1, but it works properly
when scrolling between A1 and A2.

E.g.
------------------------------------------
<html>
<body onload="document.forms['myForm'].elements['mySelect'].focus()">

<form name="myForm" id="myForm">
<select onchange="alert('onchange event');" name="mySelect"
id="mySelect">
<optgroup label="Group A">
<option value="A1">A1</option>
<option value="A2">A2</option>
<option value="A3">A3</option>
</optgroup>
<optgroup label="Group B">
<option value="B1">B1</option>
<option value="B2">B2</option>
<option value="B3">B3</option>
</optgroup>
<optgroup label="Group C">
<option value="C1">C1</option>
<option value="C2">C2</option>
<option value="C3">C3</option>
</optgroup>
</select>
</form>

</body>
</html>
------------------------------------------

Thanks,
Ryan McGeary
Jul 20 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
In article <d5*************************@posting.google.com> ,
ry*********@hotmail.com (Ryan McGeary) writes:
In a <select> drop-down, the onchange event isn't called when
scrolling through the dropdown using the mouse-wheel and when crossing
over a new <optgroup>.
Nor should it be. The onchange event shouldnt fire until a different option
(optgroups are not options) has been chosen.
Using the example below, notice how the onchange event isn't called
when mouse wheel scrolling between A3 and B1, but it works properly
when scrolling between A1 and A2.


The only way I get an alert out of that code is after I choose a different
option and leave the select list. As it should be. If you are getting the alert
simply by scrolling through the options, then something else is wrong.

--
Randy
Jul 20 '05 #2

P: n/a
Randy,

Thanks for the reply, but I think there's a misunderstanding with my
issue.

First, I'm not selecting an optgroup. I'm selecting the next option in
the list (which happens to be in the next optgroup).

Second, it's important that you use the "mouse wheel" to select between
the options to realize the issue. Do not "drop-down" the select box.
In fact, what I can tell, the mouse wheel doesn't work when the select
box is "dropped-down"; it only works when the select box is focused but
not "dropped-down."

The code I provided initially focuses on the select box; simply use your
mouse wheel and new options will be selected.

If you mouse wheel scroll between A1 and A2, the onchange event is
correctly called; however, if you mouse wheel scrool between A3 and B1,
the onchange event isn't called. I believe it should be called.

Thanks,
Ryan McGeary

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3

P: n/a
"Ryan McGeary" <ry*********@hotmail.com> wrote in message
news:d5*************************@posting.google.co m...
In a <select> drop-down, the onchange event isn't called when
scrolling through the dropdown using the mouse-wheel and when crossing
over a new <optgroup>.

Using the example below, notice how the onchange event isn't called
when mouse wheel scrolling between A3 and B1, but it works properly
when scrolling between A1 and A2.

E.g.
------------------------------------------
<html>
<body onload="document.forms['myForm'].elements['mySelect'].focus()">

<form name="myForm" id="myForm">
<select onchange="alert('onchange event');" name="mySelect"
id="mySelect">
<optgroup label="Group A">
<option value="A1">A1</option>
<option value="A2">A2</option>
<option value="A3">A3</option>
</optgroup>
<optgroup label="Group B">
<option value="B1">B1</option>
<option value="B2">B2</option>
<option value="B3">B3</option>
</optgroup>
<optgroup label="Group C">
<option value="C1">C1</option>
<option value="C2">C2</option>
<option value="C3">C3</option>
</optgroup>
</select>
</form>

</body>
</html>
------------------------------------------

Thanks,
Ryan McGeary

I'd never heard of "optgroup" before so I went looking.

I found it under WAP (Wireless Application Protocol ).

http://www.w3schools.com/wap/tag_optgroup.asp

does not indicate that "label=" is supported.
Jul 20 '05 #4

P: n/a
In article <3f*********************@news.frii.net>, Ryan McGeary
<ry*********@hotmail.com> writes:
First, I'm not selecting an optgroup. I'm selecting the next option in
the list (which happens to be in the next optgroup).

Second, it's important that you use the "mouse wheel" to select between
the options to realize the issue. Do not "drop-down" the select box.
In fact, what I can tell, the mouse wheel doesn't work when the select
box is "dropped-down"; it only works when the select box is focused but
not "dropped-down."
It took me a few minutes of tinkering to find that out. When testing it in
other browsers, IE turned out to be the only one to allow that "feature" where
I could scroll a non-dropped select list with the mouse wheel.

The mouse wheel, for me, works when the select has a scrollbar, otherwise it
doesn't. But while mouse-wheeling through a select that works with it, it
doesn't "choose" anything, just mimics me dragging the scrollbars down.
The code I provided initially focuses on the select box; simply use your
mouse wheel and new options will be selected.

If you mouse wheel scroll between A1 and A2, the onchange event is
correctly called; however, if you mouse wheel scrool between A3 and B1,
the onchange event isn't called. I believe it should be called.


I found it now. Now it has me wondering when I will ever run across it in day
to day life :) I very seldom use the mouse wheel. I guess I have become too
accustomed to dragging scrollbars and clicking the arrows on select lists :(
--
Randy
Jul 20 '05 #5

P: n/a
In article <jtoFb.615562$Tr4.1597618@attbi_s03>, "McKirahan"
<Ne**@McKirahan.com> writes:
I'd never heard of "optgroup" before so I went looking.

I found it under WAP (Wireless Application Protocol ).

http://www.w3schools.com/wap/tag_optgroup.asp

does not indicate that "label=" is supported.


I looked it up in w3c's specs, and label is not there either. But the bug still
exists with the absence of the label attribute, so while its invalid HTML, its
not the source of the bug.
--
Randy
Jul 20 '05 #6

P: n/a
Yes, it is valid HTML:

http://www.w3schools.com/tags/tag_optgroup.asp

The "label" attribute is supported by optgroup. As far as not using in
daily life, I find the optgroup tags a very useful tool in building
webapps. It can really organize a drop down list.

Also, I'm sure you can see a reason to add an onchange event handler to
a drop down. Put these two together and you have this bug.

BTW, the bug also happens when using the arrow keys instead of the mouse
wheel. Some people prefer using the keyboard instead of the mouse, so
this even further amplifies the issue.

Thanks for everyone's help! Now how do we notify Microsoft to fix the
bug?

-Ryan

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #7

P: n/a
In article <3f*********************@news.frii.net>, Ryan McGeary
<ry*********@hotmail.com> writes:
Yes, it is valid HTML:

http://www.w3schools.com/tags/tag_optgroup.asp
I looked it up in the W3C site and granted, I didn't look long, but where I did
find optgroup, it listed no label attribute. I trust the W3C specs moreso than
the w3schools site. But the validity of the HTML isn't a point with me.
The "label" attribute is supported by optgroup. As far as not using in
daily life, I find the optgroup tags a very useful tool in building
webapps. It can really organize a drop down list.
I use it also. Thats not what I was referring to in the daily life situation.
Also, I'm sure you can see a reason to add an onchange event handler to
a drop down. Put these two together and you have this bug.
Absolutely.

But you have to add one more aspect of the situation to expose the bug. And
that final aspect is what I was referring to in "daily life use", namely - the
use of the scroll wheel on a non-dropped select list. I just don't deal with
selects that way. I use the mouse and keyboard, but I want to see the entire
list. If a person is not dropping the select, when using the keyboard, then the
optgroups become useless since they will never see them - same with the
collapsed mouse wheel situation.
BTW, the bug also happens when using the arrow keys instead of the mouse
wheel. Some people prefer using the keyboard instead of the mouse, so
this even further amplifies the issue.
I agree that its a bug. I also agree that some people prefer the keyboard (I do
at times). Its something I never would have encountered because the two ways of
invoking the bug are not typical ways I deal with select lists :(
Thanks for everyone's help! Now how do we notify Microsoft to fix the
bug?


In my almost 10 years, I have yet to find a reliable way to notify Microsoft of
a bug :(
--
Randy
Jul 20 '05 #8

P: n/a
hi************@aol.com (HikksNotAtHome) writes:
I looked it up in the W3C site and granted, I didn't look long, but
where I did find optgroup, it listed no label attribute. I trust the
W3C specs moreso than the w3schools site.


<URL:http://www.w3.org/TR/html4/interact/forms.html#h-17.6.1>
Under OPTGROUP it lists the attribute:
---
label %Text; #REQUIRED -- for use in hierarchical menus --
---
and just below
---
OPTGROUP Attribute definitions

label = text [CS]
This attribute specifies the label for the option group.
---

It's not only there, it's required.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #9

P: n/a
Thanks Lasse! I thought I was going crazy. :-)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #10

P: n/a
McKirahan wrote:
[...]
<select onchange="alert('onchange event');" name="mySelect"
id="mySelect">
<optgroup label="Group A">
[...]
</optgroup>
[...]

I'd never heard of "optgroup" before so I went looking.

I found it under WAP (Wireless Application Protocol ).

http://www.w3schools.com/wap/tag_optgroup.asp

does not indicate that "label=" is supported.


`optgroup' is an element of valid HTML 4.01
Strict/Transitional as of *December 1999*.

http://www.w3.org/TR/html/interact/f...#edef-OPTGROUP

You should update your knowledge from time to time.
PointedEars
Jul 20 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.