HTML and CSS Reference
In-Depth Information
EXPLANATION
1
The HTML form starts here.
2
The input type is a text field. The onChange event is triggered when something
changes in the text field box, such as a user entering input. Instead of assigning a
function to the handle the event, the JavaScript statements are enclosed in double
quotes and will be parsed and executed when the event is triggered. It might be
less error prone to write a function than to try to keep this whole section of code
enclosed in quotes.
3
If the input assigned to grade is less than 0 or greater than 100, it is out of the legal
range, causing an alert box to appear.
4
If the input was within the limits, then the else block is executed. A confirm box
will appear to verify that this is what the user meant to type.
5
This quote marks the end of the JavaScript statements, and the > marks the end
of the input type tag.
6
The HTML form ends here. The actions of the handler are shown in Figures 13.19
through 13.21.
Figure 13.19 The user enters no value at all: There is no change.
Figure 13.20 The user enters a value. A change has taken place within the
textbox. The onChange handler is invoked.
Figure 13.21 The user enters a value. The onChange handler is invoked. The value
entered was out of range, causing the alert box to appear.
Search WWH ::




Custom Search