Keyboard JS onchange event in select boxes not fired?

CLOSED DUPLICATE of bug 126379

Status

()

Core
Event Handling
--
minor
CLOSED DUPLICATE of bug 126379
15 years ago
15 years ago

People

(Reporter: Simon Wunderlin, Assigned: joki (gone))

Tracking

Trunk
x86
Windows NT
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

15 years ago
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.
(Reporter)

Comment 2

15 years ago
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
Last Resolved: 15 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...
(Reporter)

Comment 5

15 years ago
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
You need to log in before you can comment on or make changes to this bug.