Chapter 22. Button Objects
IN THIS CHAPTER
Triggering action from a user's click of a button
Assigning hidden values to radio and checkbox buttons
Distinguishing between radio button families and their individual buttons
This chapter is devoted to those lovable buttons that invite users to initiate action and make choices with a single click of the mouse button. In this category fall the standard system-looking buttons with labels on them, as well as radio buttons and checkboxes. For such workhorses of the HTML form, these objects have a limited vocabulary of object-specific properties, methods, and event handlers.
I group together the button, submit, and reset objects for an important reason: They look alike yet they are intended for very different purposes. Knowing when to use which button is important—especially when to differentiate between the button and submit objects. Many a newcomer gets the two confused and winds up with scripting error headaches. That confusion won't happen to you by the time you finish this chapter.
The button Element Object, and the Button, Submit, and Reset Input Objects
For HTML element properties, methods, and event handlers, see Chapter 15.
Properties | Methods | Event Handlers |
---|---|---|
|
|
|
|
| |
|
| |
|
Syntax
Accessing button object properties or methods:
(All) [window.]document.formName.buttonName.property
|method
([parameters
]) (All) [window.]document.formName
.elements[index
].property
|method
([parameters
]) (All) [window.]document.forms[ ...
Get JavaScript® Bible, Sixth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.