Toggle Checkbox Selection in Javascript
Tagged:

We have often seen in webmail and other similar applications where a single checkbox at the top is used to toggle the selection of all other checkboxes in the page. The javascript function below makes it possible to achieve the same result.

Usage:
The Javascript Function

The Main page body

Name Age Sex
John 21 M
Charlie 20 M
Mary 18 F
Brown 19 M
Julie 15 F

Live Demo:
Click the checkbox on the heading to toggle the selection of all the checkboxes in the table below.

Name Age Sex
John 21 M
Charlie 20 M
Mary 18 F
Brown 19 M
Julie 15 F