JavaScript » Objects » Checkbox

A Checkbox object is created with every instance of an HTML <INPUT> tag (with a 'type' value set as 'checkbox') on a Form. These objects are then stored in the Elements array of the parent form and accessed using either the name defined within the HTML tag or an integer (with '0' being the first element defined, in source order, in the specified Form).

Properties

checked

Syntax: checkbox.checked

This property is a boolean value that sets or returns the current state of the Checkbox object; true if checked and false otherwise.

constructor

Syntax: Object.constructor

This specifies a function to create an object's property and is inherited by all objects from their prototype.

defaultChecked

Syntax: checkbox.defaultChecked

This property sets or returns the default value of the checked property.

form

Syntax: checkbox.form

This property returns a reference to the Checkbox object's parent Form.

name

Syntax: checkbox.name

This property sets or returns the Checkbox object's Name attribute.

prototype

Syntax: Object.prototype.name = value

This allows the addition of properties and methods to any object.

type

Syntax: checkbox.type

Every element on a form has an associated Type property. In the case of a Checkbox object, the value of this property is always "checkbox".

value

Syntax: checkbox.value

This property sets the Value that is returned when the Checkbox is checked.

Methods

blur

Syntax: checkbox.blur( )

This method removes the Focus from the specified Checkbox object.

click

Syntax: checkbox.click( )

This method simulates a mouse-click on the Checkbox object.

eval

Syntax: Object.eval(string)

The eval method is deprecated as a method of Object, but is still used as a high level function. It evaluates a string of JavaScript in the context of an object.

focus

Syntax: checkbox.focus( )

This method gives Focus to the specified Checkbox object.

handleEvent

Syntax: checkbox.handleEvent(event)

This method calls the handler for the specified Event.

toSource

Syntax: Object.toSource()

The toSource method returns a literal representing the source code of an object. This can then be used to create a new object.

toString

Syntax: Object.toString()

The toString method returns a string representing a specified object.

unwatch

Syntax: Object.unwatch(property)

This method removes a watchpoint set for an object and property name with the watch method.

valueOf

Syntax: Object.valueOf()

This method returns a primitive value for a specified object.

watch

Syntax: Object.watch(property, handlerfunction)

This method adds a watchpoint to a property of the object.

See Also: