CoderZone.org

Category: >> JavaScript >> Check or Uncheck all Checkboxes Bookmark and Share

<< 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)

Author: CoderZone
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;
}
 
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 3