Checkbox

The checkbox form element.

Properties

checked

FF, IE 3

true if a visitor has selected the checkbox, false otherwise. Setting the property to true will cause the checkbox to act as if a visitor had selected the box.

form

FF, IE 3

Read-only: Form containing the checkbox

name

FF, IE 3

Name of a checkbox

type

FF, IE 3

Read-only: Set to 'checkbox'

value

FF, IE 3

Value of the checkbox

Example:

if (window.document.my_form.the_checkbox.checked == true)
{
    alert("Thanks for clicking the checkbox!");
}

Handlers

onClick

FF, IE 3

Triggered when a visitor clicks the checkbox

Methods

click()

FF, IE 3

Simulates the act of clicking the checkbox

Get The Book of JavaScript, 2nd 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.