Snippet Name: Check or Uncheck all Checkboxes
Description: Use this Javascript function to check or uncheck all the checkboxes in a form. This function is specially designed for dynamic pages with varying numbers of checkboxes.
Comment: (none)
Language: JAVASCRIPT
Highlight Mode: JAVASCRIPT
Last Modified: February 27th, 2009
|
FUNCTION SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
IF(!document.forms[FormName])
RETURN;
VAR objCheckBoxes = document.forms[FormName].elements[FieldName];
IF(!objCheckBoxes)
RETURN;
VAR countCheckBoxes = objCheckBoxes.length;
IF(!countCheckBoxes)
objCheckBoxes.checked = CheckValue;
ELSE
// set the check value for all check boxes
FOR(VAR i = 0; i < countCheckBoxes; i++)
objCheckBoxes[i].checked = CheckValue;
}
|