Closed Bug 166829 Opened 22 years ago Closed 22 years ago

Keyboard JS onchange event in select boxes not fired?

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

x86
Windows NT
defect
Not set
minor

Tracking

()

CLOSED DUPLICATE of bug 126379

People

(Reporter: swunderlin, Assigned: joki)

Details

Discovered in Mozilla 1.1 final on Windows NT4 SP5 (other platforms untested):

having discovered that an onchange event in a select box is not fired. This only
happens if the chackbox is changed via keyboard (mouse works fine).

Example: 

<form>
	<select name="blah" 
	onchange="alert(this.options[this.selectedIndex].value);">
		<option value="1">1
		<option value="2">2
		<option value="3">3
	</select>
</form>
It fires fine.  It just fires when the value has actually _changed_ (ie when the
<select> loses focus), not while the user is scrolling through the select with
keyboard looking for the right value.
i might have been a bit unprecise. When selecting with the keyboard the onchage
seems to behave like the onblur event.

This is not the case when using the mouse (where onchange is actually fired when
another <option> is selected).
This is needed to allow keyboard users to scroll through the select without
triggering onchange when all they're doing is getting to the option they want. 
See bug 110800

*** This bug has been marked as a duplicate of 126379 ***
Status: UNCONFIRMED → RESOLVED
Closed: 22 years ago
Resolution: --- → DUPLICATE
Note also the definition of "onchange" in the HTML spec:

  The onchange event occurs when a control loses the input focus and its value has
  been modified since gaining focus. This attribute applies to the following
  elements: INPUT, SELECT, and TEXTAREA.

It's like firing onchange for every char typed in a text input...
Thank you for clarifiying this. I was confused due to that fact that Netscape
4.X and all IE's do not act like this.
Status: RESOLVED → CLOSED
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.