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:

Leave a reply:

Your email address will not be published.

*

Site Footer

Sliding Sidebar

Disclaimer

The contents on this blog are not intended as professional advice. The author disclaims any liability, loss, or risk taken by individuals who directly or indirectly act on the information contained on this blog.