Categories:

Home / Free JavaScripts / Forms / Here

Cut & Paste Check all check/radio buttons

Credit: JavaScript Kit

Description: A good addition to your forms if they contain a multitude of check/radio buttons is a "check/uncheck all" feature. This script does just that for any group of checkboxes and radio buttons. Useful!

Example:

Peter
Jane
George
Check All
Uncheck All

Directions:

Step 1: Add the following to the HEAD section of your page:

Step 2: Add the following to the BODY section of your page:

The above contains a sample form with the "check/uncheck" links added. To set up your own links, follow the same format:

<a href="javascript:checkall('test','v1',true)">Check All</a><br>
<a href="javascript:checkall('test','v1',false)">Uncheck All</a>
The first parameter should contain the name of your form, the second the common name of checkboxes you're grouping together, and lastly, whether they should be checked or unchecked (pass true for former).

Copyright 1997-2007 JavaScript Kit. NO PART may be reproduced without author's permission.