|
|
|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
(Publisher: Macmillan Computer Publishing)
Author(s): Eric Ladd
ISBN: 078971759x
Publication Date: 11/01/98
Table 19.7 HTML Form input Object Properties, Methods, and Events
|
|
Property
| What It Contains
|
|
name
| the value of the elements NAME attribute
|
value
| the fields contents
|
defaultValue
| the initial contents of the field
|
|
|
Method
| What It Does
|
|
focus()
| moves the input focus to the specified object
|
blur()
| moves the input focus away from the specified object
|
select()
| selects the specified object
|
submit()
| submits the form according to its ACTION and METHOD attributes
|
|
Event
| When It Occurs
|
|
onFocus
| triggered when the user moves the input focus to the field, either via the Tab key or a mouse click
|
onBlur
| triggered when the user moves the input focus out of this field
|
onSelect
| triggered when the user selects text in the field
|
onSubmit
| triggered when the form is submitted
|
onChange
| triggered only when the field loses focus and the user has modified its text; use this action to validate data in a field
|
|
Individual buttons and check boxes have properties, too; JavaScript provides properties to get objects containing a buttons data, as well as methods for doing something when the user selects or deselects a particular button. Table 19.8 shows some of the properties, methods, and events defined for button elements.
Table 19.8 HTML Form radio and checkbox Object Properties, Methods, and Events
|
|
Property
| What It Contains
|
|
name
| the value of the buttons NAME attribute
|
value
| the VALUE attribute
|
checked
| the state of a check box
|
defaultChecked
| the initial state of a check box
|
|
|
Method
| What It Does
|
|
focus()
| moves the input focus to the specified object
|
blur()
| moves the input focus away from the specified object
|
click()
| clicks a button and triggers whatever actions are attached to it
|
submit()
| submits the form according to its ACTION and METHOD attributes
|
|
Event
| When It Occurs
|
|
onClick
| triggered when the button is pressed
|
onFocus
| triggered when the user moves the input focus to the field, either via the Tab key or a mouse click
|
onBlur
| triggered when the user moves the input focus out of this field
|
onSubmit
| triggered when the form is submitted
|
onChange
| triggered only when the field loses focus and the user has modified its text; use this action to validate data in a field
|
|
For more details and examples of what you can do with JavaScript and the objects, properties, and methods associated with HTML forms, see Chapter 21, Using JavaScript to Create Smart Forms.
- See Client-Side Form Validation, p. 514.
The image Object
The last Web browser object to be discussed in this chapter is the image object. One image object is created in a document by each <IMG> tag on the page. These objects are referenced through an images object array; the objects array has a length property that you can use to find out how many images are present. Table 19.9 shows some of the other properties and events associated with the image object.
|