HTML and CSS Reference
In-Depth Information
EXAMPLE 13.15 ( CONTINUED )
3
<form name="form1">
<p>Type your name:
4
< input type="text"
name="namestring"
size="50"
5
onFocus="handler('Don\'t forget to enter your name')">
<br />Talk about yourself here:<br />
6
< textarea name="comments"
align="left"
7
onFocus="handler('Did you add comments?')"
rows="5" cols="50">I was born...
</textarea><p>
<input type="button"
value="submit">
<input type="reset"
value="clear">
</form>
</body>
</html>
EXPLANATION
1
A user-defined function called handler() is defined. It takes a string as its only
parameter.
2
The string message, “Don't forget to enter your name” (or “Did you add comments?”)
is passed to the function and assigned to the window's status bar. (If you don't see
anything in the status bar, the feature has been disabled for your browser. For
Firefox go to the View option and click Status bar. For Safari, View, and click Hide
Status Bar.)
3
The HTML form starts here.
4
The first input type is a textbox.
5
The textbox contains the attribute for the onFocus event handler. When this box
has focus, the event will be fired up and call the handler() function.
6
A text area is defined to hold user comments.
7
The text area contains the attribute for the onFocus event handler. When this
box has focus, the event will be fired up and call the handler() function. See
Figure 13.18.
Search WWH ::




Custom Search