DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Check / Uncheck All Checkboxes In A Pseudo Group
This bit of javascript will check and uncheck all checkboxes in a group of checkboxes. The checkboxes are grouped by naming all the checkboxes by the same name.
Javascript Code:
function checkUncheckAll(checkAllState, cbGroup)
{
for (i = 0; i < cbGroup.length; i++)
{
cbGroup[i].checked = checkAllState.checked;
}
}
HTML Code:
<input type=checkbox name=checkall onclick="checkUncheckAll(this, grp1);"> <input type=checkbox name=grp1 id=bx1> <input type=checkbox name=grp1 id=bx2> <input type=checkbox name=grp1 id=bx3> <input type=checkbox name=grp1 id=bx4>




