onchange event
Fires when the contents of the object or selection have changed.
Syntax
HTML Attribute | <element onchange = "handler(event)"> |
Event Property | object.onchange = handler; |
attachEvent Method | object.attachEvent("onchange", handler) |
addEventListener Method | object.addEventListener("change", handler, useCapture) |
Event information
Synchronous | No |
Bubbles | No |
Cancelable | Yes |
Event handler parameters
- pEvtObj [in]
Type: IHTMLEventObj
Standards information
- HTML 4.01 Specification, Section 18.2.3
Remarks
This event is fired when the contents are committed and not while the value is changing. For example, on a text box, this event is not fired while the user is typing, but rather when the user commits the change by leaving the text box that has focus. In addition, this event is executed before the code specified by HTMLTextContainerEvents2::onblur when the control is also losing the focus.
The HTMLTextContainerEvents2::onchange event does not fire when the selected option of the select object is changed programmatically.
Changed text selection is committed.
To invoke this event, do one of the following:
- Choose a different option in a select object using mouse or keyboard navigation.
- Alter text in the text area and then navigate out of the object.
The pEvtObj parameter is required for the following interfaces:
- HTMLAnchorEvents2
- HTMLAreaEvents2
- HTMLButtonElementEvents2
- HTMLControlElementEvents2
- HTMLDocumentEvents2
- HTMLElementEvents2
- HTMLFormElementEvents2
- HTMLImgEvents2
- HTMLFrameSiteEvents2
- HTMLInputFileElementEvents2
- HTMLInputImageEvents2
- HTMLInputTextElementEvents2
- HTMLLabelEvents2
- HTMLLinkElementEvents2
- HTMLMapEvents2
- HTMLMarqueeElementEvents2
- HTMLObjectElementEvents2
- HTMLOptionButtonElementEvents2
- HTMLScriptEvents2
- HTMLSelectElementEvents2
- HTMLStyleElementEvents2
- HTMLTableEvents2
- HTMLTextContainerEvents2
- HTMLWindowEvents2