JavaScript Checkbox Object

The JavaScript Checkbox object is a property of the form object. Checkbox FORM syntax is:

<INPUT TYPE="checkbox" NAME="Item1" VALUE="1" CHECKED onClick="clickFunction">

Here's how it looks:


The button belongs to the checkBox group of buttons and any combination in that group should be checked. The clickFunction is run when the button is clicked and must exist, usually in the header. The value is the value returned when the button is checked. The option "CHECKED" sets the button so it is selected when it is initially displayed. Both the onClick and CHECKED parameters are optional. Type, name, and value are required.

Properties

  • checked - The value is true when the button is checked.
  • defaultChecked - Is true if the button is checked by default.
  • form - The form object that includes the checkbox button.
  • name - The name of the checkbox button.
  • type - The type of element which is checkbox.
  • value - The value of the button.

Methods

  • blur() - Takes the focus away from the checkbox.
  • click() - This function acts as if the user clicked the checkbox. This function may be used to undo any user action on a checkbox, such as when a user clicks the box, if this function is called, it will undo the user's action. Also this function may be used to link the clicking of multiple checkboxes together.
  • focus() - Gives the focus to the checkbox.

Events

  • onBlur
  • onClick
  • onFocus