JavaScript onchange Event
Complete Event 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 Reference
Whether you're new to XML or already an advanced user, the user-friendly views
and powerful entry helpers, wizards, and debuggers in XMLSpy are designed to
meet your XML and Web services development needs from start to finish.
- XML editor
- Graphical XML Schema / DTD editors
- XSLT 1.0/2.0 editor, debugger, profiler
- XQuery editor, debugger, profiler
- Support for Office Open XML (OOXML)
- Graphical WSDL editor & SOAP debugger
- Java, C#, C++ code generation
- And much more!
Download a fully functional free 30-day trial today!
|