1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| // Check/Uncheck button text per group
var checkTable = new Array();
// Check all variables of the specified group
function checkAll(groupid)
{
// Invert button text
checkTable[groupid] = !checkTable[groupid];
// HTMLTableRowElement -> HTMLCollection
var cells = document.getElementById(groupid).cells;
// For each cell of the group table
for (i=0; i<cells.length; i++)
{
// HTMLTableCellElement
nodes = cells.item(i).childNodes;
// For each node of the cell
for (j=0; j<nodes.length; j++)
{
node = nodes.item(j);
// If the node is a checkbox, check or uncheck it
if (node instanceof HTMLInputElement)
{
node.checked = checkTable[groupid];
}
}
}
// Invert button text
if (checkTable[groupid])
return "Uncheck All";
else
return "Check All";
} |