onchange Event
Complete Event Object Reference
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>
|
The output of the code above will be:
Try-It-Yourself Demos
onchange
How to use the onchange event to execute some JavaScript code when a user
changes the content of
an input field.
Complete Event Object Reference
Want To Be A Web Master?
If you want to be a Web Master, you will have to host your web site with an ISP (Internet Service Provider).
MaximumASP offers seven different configurations of dedicated servers to meet your Windows and .NET hosting needs.
Hosted on our multi-tiered Enterprise Class network, these servers provide the performance, security and reliability
you need to host your high end web sites and applications.
Visit MaximumASP
|