Let's use form elements and these event-handlers to create a calculator that converts distances from miles to kilometers. We use the conversion 1 mile = 1.609 kilometers. We use text boxes (<input type=text>) to hold all the information in the calculator.
To demonstrate how 'onChange' works, let's ask the user what state he is from, and then echo the name of the state back to him in a different text box.
Here is the script:
<p>What state do you reside in?
<input type=text name="state" size=30 onChange="stateResults.value = state.value"><br><p>
<p>Miles: <input type=text name="miles" size=10>
<input type=button value=" ---> " name="convert" onClick="kilometers.value = miles.value * 1.609">
<p>Kilometers: <input type=text name="kilometers" size=10><br>
<p><center><input type=reset></center> <p>
<p>Dear resident of the state of <input type=text name="stateResults" size=30>, yours is one of the truly great states of this country!
<p style="font-size:8pt">Then again, I say that to everybody.