[thelist] checkbox that auto-checks other checkboxes

.jeff jeff at members.evolt.org
Sun Jan 19 01:28:00 CST 2003


rudy,

[replying late]

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: rudy
>
> >... i think it's easier to use than irt.org's version.
> > http://members.evolt.org/jeff/code/checkbox_check_all.cfm
>
> that's true
>
> but it's an order of magnitude harder to understand
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

i think you're making things harder on yourself than they need to be.
first, make sure all checkboxes that are to be connected have the same name.
then, all you do is add the following snippet to the checkbox you wish to
use to control all the other checkboxes:

 onclick="toggleChecked(this)"

and add the following snippet to the rest of the checkboxes that are named
the same (if you want the "check all" checkbox to be set to an indeterminate
state if only some of the other checkboxes are checked):

 onclick="toggleIndeterminate(this)"

copy and paste the first two functions in the document -- toggleChecked() &
toggleIndeterminate().  that's literally all you have to do to make this
work.

in fact, with these two functions, you could multiple groups of checkboxes,
each with their own "check all" checkbox and not have to touch the functions
for everything to work properly.

good luck,

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/




More information about the thelist mailing list