JC5 0 Posted May 25, 2009 Report Share Posted May 25, 2009 (edited) Well, the behavior I'm looking for is this:I have 9 checkboxes. 1 to 8 are this and that. 9 is "all"All of them start out checked.When I uncheck one (any one) I want "all" (checkbox 9) to unchecked.When all are checked I want "all" (checkbox 9) to be checked.Can anyone help me? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html lang="en"><head><script type="text/javascript">function checkAll(check) { for (i=0;i<10;i++) { if (check) { document.forms['thisone'].chbx[i].checked=true; } else { document.forms['thisone'].chbx[i].checked=false; } } }</script></head><body><form id="thisone"><input type=checkbox name="chbx" onClick="checkAll(false)" checked="checked"><input type=checkbox name="chbx" onClick="checkAll(false)" checked="checked"><input type=checkbox name="chbx" onClick="checkAll(false)" checked="checked"><input type=checkbox name="chbx" onClick="checkAll(false)" checked="checked"><input type=checkbox name="chbx" onClick="checkAll(false)" checked="checked"><input type=checkbox name="chbx" onClick="checkAll(false)" checked="checked"><input type=checkbox name="chbx" onClick="checkAll(false)" checked="checked"><input type=checkbox name="chbx" onClick="checkAll(false)" checked="checked"><input type=checkbox name="chbx" onClick="checkAll(false)" checked="checked"><input type=checkbox name="chbx" onClick="checkAll(false)" checked="checked"></form></body></html> Edited May 25, 2009 by GH4 Quote Link to post Share on other sites
Ingolme 1,032 Posted May 25, 2009 Report Share Posted May 25, 2009 Give the "all" box an id, for example id="all"When you click on any box that's not the "all" box, loop through all the checkboxes checking if they're checked or not. If any of them are not checked, then uncheck the "all" box. Quote Link to post Share on other sites
JC5 0 Posted May 25, 2009 Author Report Share Posted May 25, 2009 oK thanks. Got it working Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.