JavaScript and Checkboxes

This part of the JavaScript and Forms Tutorial answers these common questions regarding JavaScript and checkboxes:

The pages listed above demonstrate, explain, and display the JavaScript.

Basic Facts about Checkboxes

Checkboxes can be set up individually or in groups. Groups of checkboxes can have the same name or their names can be distinct. Typical uses for checkboxes are yes or no questions (such as agreeing to terms of use), or lists of choices where more than one is possible (such as pizza toppings).

When you use JavaScript to interact with checkboxes, you will most often be working with the checked and value properties. The examples listed above demonstrate how to access and use these properties.

Up-to-date browsers support both onchange and onclick events on checkboxes. However, Internet Explorer prior to version 9 does not support the onchange event on checkboxes.