Definition and Usage The onchange event occurs when the content of a field changes. Syntax onchange="SomeJavaScriptCode" ...
Definition and Usage
The onchange event occurs when the content of a field changes.
Syntax
onchange="SomeJavaScriptCode" |
Parameter | Description |
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs. |
Supported by the following HTML tags:
<input type="text">, <select>, <textarea> |
Supported by the following JavaScript objects:
fileUpload, select, text, textarea |
Example
In this example we will execute some JavaScript code when a user changes the content of an input field:
<html>
<head>
<script type="text/javascript">
function upperCase(x)
{
var y=document.getElementById(x).value;
document.getElementById(x).value=y.toUpperCase();
}
</script>
</head> <body> Enter your name:
<input type="text" id="fname"
onchange="upperCase(this.id)"> </body>
</html> |