Quick Search:
 
 JavaScript: Check or Uncheck all Checkboxes Jump to:  
Category: >> JavaScript >> Check or Uncheck all Checkboxes  

<< lastnext >>

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;
}
 


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org