input (type="checkbox")NN 2 IE 3 DOM 1  

  

The checkbox object is a form control generated with an input element whose type attribute is set to "checkbox". Employ this element only as a user interface element for user on-off choices, not as a navigation button. In IE 5 and later for Windows and in Netscape 6, you can adjust the size of the checkbox via style sheet height and width attributes, but only Netscape 6 automatically scales the size of the checkmark optimized for the checkbox rectangle's size and keeps the baselines of surrounding text aligned with the rectangle's bottom.

 
HTML Equivalent
 
<input type="checkbox">
 
Object Model Reference
 
[window.]document.formName.elementName
[window.]document.forms[i].elements[i]
[window.]document.getElementById("elementID")
 
Object-Specific Properties
 
checkeddataFlddataSrcdefaultCheckedform
indeterminatenamestatustypevalue
 
Object-Specific Methods
 
handleEvent[ ]
 
Object-Specific Event Handler Properties
 
HandlerNNIEDOM
onblur642
onclick342
onfocus642
onmousedown442
onmousemove642
onmouseout642
onmouseover642
onmouseup442
checkedNN 2 IE 3 DOM 1  

Read/Write  

Specifies whether the checkbox is selected or turned on by the user (or script). Checkboxes operate independently of each other. Only checkbox objects with the checked property set to true have their name/value pair submitted with the form. To find out whether the form element is set to be checked when the page loads, see the defaultChecked property. Scripts can change this property even if the element is disabled.

 
Example
 
if (document.choiceForm.monitors.checked) {
    //process for the "monitors" checkbox being checked
}
 
Value

Boolean: true | false.

 
Default

false

dataFldNN n/a IE 4 DOM n/a  

Read/Write  

Used with IE 4 data binding to associate a remote data source column name to a checkbox object's value attribute. A datasrc attribute must also be set for the element. Setting both the dataFld and dataSrc properties to empty strings breaks the binding between element and data source. Works only with text file data sources in IE 5/Mac.

 
Example
 
document.myForm.myCheckbox.dataFld = "homeAddrFlag";
 
Value

Case-sensitive identifier of the data source column.

 
Default

None.

dataSrcNN n/a IE 4 DOM n/a  

Read/Write  

Used with IE data binding to specify the ID of the page's object element that loads the data source object for remote data access. Content from the data source is specified via the datafld attribute. Setting both the dataFld and dataSrc properties to empty strings breaks the binding between element and data source. Works only with text file data sources in IE 5/Mac.

 
Example
 
document.myForm.myCheckbox.dataSrc = "DBSRC3";
 
Value

Case-sensitive identifier of the data source.

 
Default

None.

defaultCheckedNN 2 IE 3 DOM 1  

Read/Write  

Specifies whether the element has the checked attribute set in the tag. You can compare the current checked property against defaultChecked to see whether the state of the control has changed since the document loaded. Changing this property does not affect the current checked status.

 
Example
 
var cBox = document.forms[0].checkbox1
if (cBox.checked != cBox.defaultChecked) {
    // process for changed state
}
 
Value

Boolean value: true | false.

 
Default

Determined by HTML tag attribute.

formNN 2 IE 3 DOM 1  

Read-only  

Returns a reference to the form element that contains the current element (if any). When processing an event from this element, the event handler function automatically has access to the input element (as the event object's target or srcElement property). By reading the form property, the script can easily access other controls within the same form.

 
Example
 
var theForm = evt.srcElement.form;
 
Value

form element object reference.

 
Default

None.

indeterminateNN n/a IE 4 DOM n/a  

Read/Write  

Indicates whether a checkbox is visually represented as being neither checked nor unchecked, yet still active. This middle ground is rendered differently for different operating systems. In Windows, the checkbox is grayed out (with the checkmark still visible if it was there originally) but still active. On the Macintosh, the checkbox displays a hyphen inside the box. The indeterminate state usually means some change elsewhere on the page has likely affected the setting of the checkbox, requiring the user to verify the checkbox's setting for accuracy. An "indeterminate" checkbox is submitted with the form.

 
Example
 
document.orderForm.2DayAir.indeterminate = true;
 
Value

Boolean value: true | false.

 
Default

false

nameNN 2 IE 3 DOM 1  

Read/Write  

This is the identifier associated with the form control. The value of this property is submitted as one-half of the name/value pair when the form is submitted to the server. Names are hidden from user view, since control labels are assigned via other means, depending on the control type. Form control names may also be used by script references to the objects. Despite the modern standards' preference for the id attribute, many browsers still require that a form control be assigned a name attribute to allow the control's value to be submitted.

 
Example
 
document.orderForm.myCheckbox.name = "Win32";
 
Value

Case-sensitive string identifier that follows the rules of identifier naming: it may contain no whitespace, cannot begin with a numeral, and should avoid punctuation except for the underscore character.

 
Default

None.

statusNN n/a IE 4 DOM n/a  

Read/Write  

Specifies whether the element is highlighted/checked. This property is identical to the checked property.

 
Example
 
if (document.forms[0].56KbpsBox.status) {
    ...
}
 
Value

Boolean value: true | false.

 
Default

None.

typeNN 3 IE 4 DOM 1  

Read-only  

Returns the type of form control element. The value is returned in all lowercase letters. It may be necessary to cycle through all form elements in search of specific types to do some processing on (e.g., emptying all form controls of type "text" while leaving other controls untouched).

 
Example
 
if (document.forms[0].elements[3].type == "checkbox") {
    // process checkbox input type here
}
 
Value

Any of the following constants (as a string): button | checkbox | file | hidden | image | password | radio | reset | select-multiple | select-one | submit | text | textarea.

 
Default

checkbox

valueNN 2 IE 3 DOM 1  

Read/Write  

Provides the current value associated with the form control that is submitted with the name/value pair for the element (if the checkbox is checked). All values are strings, but they may represent other kinds of data, including Boolean and numeric values.

 
Example
 
document.forms[0].extraPhone.value = "cellPhone";
 
Value

String.

 
Default

None.

handleEvent[ ]NN |4| IE n/a DOM n/a  

handleEvent(event)

  

Instructs the object to accept and process the event whose specifications are passed as the parameter to the method. The object must have an event handler for the event type to process the event. Navigator 4 only.

 
Parameters
 
  • A Navigator 4 event object.
 
Returned Value

None.