JAVASCRIPT

 Home  Computers & Internet  Web Programming JAVASCRIPT
What is Javascript?
Javascript Placement
Syntax
Reserved Words
Variables
Data Types
Escaping Characters
Concatenation
Arithmetic Operators
Assignment Operators
Comparison Operators
Boolean Operators
Conditional Operator
If Statements
Else If Statements
If Else Statements
Switch Statements
While Loops
For Loops
Do While Loops
Break Statement
Continue Statement
prompt()
alert()
Date()
Event Handlers
String Object Methods
Math Object Methods
Window Object Methods
Arrays

JAVASCRIPT ONCHANGE EVENT

The javascript onchange event handler is used to trigger a script or action when a user makes a content change to either <input>, <textarea> or <select> element.

Example:

<form action="#" method="post">
<select onchange="alert('You have made a change');">
<option select="selected">One</option>
<option >Two</option>
<option >Three</option>
</select>
</form>

The above example will output You have made a change when you select a new option.

The onchange event can also call a function as follows:

<head>

<script type="text/javascript">

function changeme ()
{
alert('You have made a change');
}

</script>

</head>

<body>

<form action="#" method="post">
<select onchange="changeme ();">
<option select="selected">One</option>
<option >Two</option>
<option >Three</option>
</select>
</form>

DEMO:

Change the select option below to see the effect.



See also:

onload
onunload
onclick
ondblclick
onmousedown
onmouseup
onmouseover
onmousemove
onmouseout
onkeypress
onkeydown
onkeyup
onfocus
onblur
onsubmit
onreset
onselect


Home | Privacy Policy | Terms Of Use | Contact Us