change

< dom‎ | events
Jump to: navigation, search



Overview Table

Synchronous No
Bubbles No
Target dom/Element
Cancelable No
Default action

Examples

View live exampleThis example uses the onchange event to retrieve the selected option of a select object.

<body>
<form>
  <p>Select a different option in the drop-down list box to trigger the onchange event.
  <select name="selTest" onchange="alert('Index: ' + this.selectedIndex
     + '\nValue: ' + this.options[this.selectedIndex].value)">
  <option value="Books">Books</option>
  <option value="Clothing">Clothing</option>
  <option value="Housewares">Housewares</option>
  </select> </p>
</form>
</body>

Notes

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 onblur when the control is also losing the focus. The 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

Syntax

Standards information


Event handler parameters

pEvtObj [in]
Type: IHTMLEventObj

See also

Related pages (MSDN)

  • a
  • abbr
  • acronym
  • address
  • applet
  • area
  • audio
  • b
  • base
  • baseFont
  • bdo
  • bgSound
  • big
  • body
  • blockQuote
  • br
  • button
  • canvas
  • caption
  • center
  • cite
  • code
  • col
  • colGroup
  • comment
  • custom
  • dd
  • del
  • dfn
  • dir
  • div
  • dl
  • document
  • dt
  • em
  • embed
  • fieldSet
  • font
  • form
  • frame
  • frameSet
  • head
  • hn
  • hr
  • html
  • i
  • iframe
  • img
  • input type=button
  • input type=checkbox
  • input type=file
  • input type=hidden
  • input type=image
  • input type=password
  • input type=radio
  • input type=reset
  • input type=submit
  • input type=text
  • ins
  • isIndex
  • kbd
  • label
  • legend
  • li
  • link
  • listing
  • map
  • marquee
  • media
  • menu
  • meta
  • nextID
  • noBR
  • noFrames
  • noScript
  • object
  • ol
  • optGroup
  • option
  • p
  • param
  • plainText
  • pre
  • q
  • rt
  • ruby
  • s
  • samp
  • script
  • select
  • small
  • source
  • span
  • strike
  • strong
  • style
  • sub
  • sup
  • table
  • tBody
  • td
  • textArea
  • tFoot
  • th
  • tHead
  • title
  • tr
  • tt
  • u
  • ul
  • var
  • wbr
  • video
  • window
  • xmp
  • onkeypress

This article contains content originally from external sources.

Portions of this content come from the Microsoft Developer Network: [Windows Internet Explorer API reference Article]