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: