Select.onChange

JavaScript1.0+, JScript1.0+ Nav2+, IE3+, Opera3+ Syntax

onChange="command"

Description

The onChange event handler of an instance of a Select object is fired when the option selected in the select box is changed. Care should be taken when using this event handler, because it is possible to get into an infinite loop when using other event handlers or methods that are fired when focus is placed on or away from the select box.

Example

Listing 7.471 has a single select box. If the user changes the selected option, an alert box is displayed showing the option that has been selected.

Listing 7.471 Using the onChange Event Handler to Display an Alert Box When an Option Is Selected in the Select Box
 <html> <head> <script language="JavaScript"> ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.