Checkbox Object
The Checkbox object represents a checkbox on an HTML form.
For each instance of an HTML <input type="checkbox"> tag on an
HTML form, a Checkbox object is created.
All Checkbox objects are stored in the elements array of the corresponding form.
You can access a Checkbox object by indexing this array - either by number (0
represents the first element in a form) or by using the value of the name
attribute.
The Checkbox object's properties, methods, and events are
described below:
N: Netscape (including Mozilla when N6 or higher), IE: Internet Explorer, W3C:
World Wide Web Consortium (Internet Standard)
Properties
Syntax: object.property_name
Property |
Description |
N |
IE |
W3C |
accept |
Sets or returns a list of content types that the server
that processes this form will handle correct |
|
- |
Yes |
accessKey |
Sets or returns the keyboard key to access the checkbox |
|
4 |
Yes |
align |
Sets or returns the alignment of the checkbox according to
the surrounding text |
|
- |
Yes |
alt |
Sets or returns an alternate text to display if the browser
does not support checkboxes |
|
- |
Yes |
checked |
Sets or returns the current state of the checkbox (true if
checked and false if not) |
2 |
3 |
Yes |
defaultChecked |
Sets or returns the default value of the checked attribute (true if
checked by default and false if not) |
2 |
3 |
Yes |
disabled |
Sets or returns whether or not the checkbox should be
disabled |
|
3 |
Yes |
form |
Returns a reference to the form that contains the checkbox |
2 |
3 |
Yes |
id |
Sets or returns the id of the checkbox (In IE 4 this
property is read-only) |
|
4 |
No |
name |
Sets or returns the name of the checkbox |
2 |
3 |
Yes |
tabIndex |
Sets or returns the index that defines the tab order for
the checkbox |
|
4 |
Yes |
type |
Returns the type of the form element. For a checkbox
it will be "checkbox" |
3 |
4 |
Yes |
value |
Sets or returns the value of the value attribute of the
checkbox |
2 |
3 |
Yes |
Methods
Syntax: object.method_name()
Method |
Description |
N |
IE |
W3C |
blur() |
Removes focus from the checkbox |
2 |
3 |
Yes |
click() |
Simulates a mouse-click in the checkbox |
2 |
3 |
Yes |
focus() |
Gives focus to the checkbox |
2 |
3 |
Yes |
Events
Syntax: object.event_name="someJavaScriptCode"
Event |
Description |
N |
IE |
W3C |
onBlur |
Executes some code when the checkbox loses focus |
2 |
3 |
|
onClick |
Executes some code when the checkbox is clicked |
2 |
3 |
|
onFocus |
Executes some code when the checkbox gets focus |
2 |
3 |
|
onMouseDown |
Executes some code when a mouse button is pressed |
4 |
4 |
|
onMouseUp |
Executes some code when a mouse button is released |
4 |
4 |
|
|