Name
Checkbox — a graphical checkbox
Availability
JavaScript 1.0; enhanced in JavaScript 1.1
Inherits from/Overrides
Inherits from Input, HTMLElement
Synopsis
A single Checkbox element with a unique name may be referenced in either of these ways:
form.checkbox_name
form.elements[i]
When a form contains a group of checkboxes with the same name, they are placed in an array and may be referenced as follows:
form.checkbox_name[j] form.checkbox_name.length
Properties
Checkbox inherits properties from Input and HTMLElement and defines or overrides the following:
-
checked
A read/write boolean property. If the checkbox is checked, the
checked
property istrue
. If the checkbox is not checked,checked
isfalse
.
If you set checked
to true
, the
checkbox appears checked. Similarly, if you set this property to
false
, the checkbox appears unchecked. Note that
setting the checked
property does not cause the
Checkbox element’s onclick
event handler to
be invoked.
-
defaultChecked
A read-only boolean that specifies the initial state of the checkbox. It is
true
if the checkbox is initially checked -- i.e., if thechecked
attribute appears in the checkbox’s HTML<input>
tag. If this attribute does not appear, the checkbox is initially unchecked anddefaultChecked
isfalse
.-
value
A read/write string property that specifies the text passed to the web server if the checkbox is checked when the form is submitted. The initial value of
value
is specified by thevalue
attribute of the checkbox’s HTML<input> ...
Get JavaScript: The Definitive Guide, Fourth 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.