How To Check All Checkboxes In A Form With Javascript

//How To Check All Checkboxes In A Form With Javascript

How To Check All Checkboxes In A Form With Javascript

I had an application that had a long list of checkboxes in a form. I wanted the ability to check all the checkboxes at once, or uncheck them at once. However, after googling for a solution, it seemed that all of them required me to label all my checkboxes with the same name. The nature of my application didn’t allow me to do that, so I had to find my own solution.

The following Javascript code allows you to toggle (check or uncheck) all the checkboxes in your form. Just put this Javascript code chunk on a new line anywhere in the body of your webpage.


And you can use it with any form on your page, like this:

And here is a sample of how it works:





Similar Posts:

By |2011-03-31T02:08:02+00:00April 11th, 2011|Tutorials & Tips|0 Comments

About the Author:

Alvin Poh lives in Singapore, and is interested in marketing, techy stuff, and likes to just figure out how the two can work with each other. He can also be found on Google+.

Leave A Comment


*