Posted By

scriptmakingcom on 09/14/07


Tagged

javascript check checkboxes uncheck


Versions (?)

Who likes this?

7 people have marked this snippet as a favorite

jonhenshaw
luman
vali29
SpinZ
leitmotiv
korzhik
seanpowell


Check or Uncheck all checkboxes on a form


 / Published in: JavaScript
 

URL: http://www.somacon.com/p117.php

  1. function SetAllCheckBoxes(FormName, FieldName, CheckValue)
  2. {
  3. if(!document.forms[FormName])
  4. return;
  5. var objCheckBoxes = document.forms[FormName].elements[FieldName];
  6. if(!objCheckBoxes)
  7. return;
  8. var countCheckBoxes = objCheckBoxes.length;
  9. if(!countCheckBoxes)
  10. objCheckBoxes.checked = CheckValue;
  11. else
  12. // set the check value for all check boxes
  13. for(var i = 0; i < countCheckBoxes; i++)
  14. objCheckBoxes[i].checked = CheckValue;
  15. }

Report this snippet  

You need to login to post a comment.