Check or Uncheck all checkboxes on a form


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.