Autocheck Checkbox


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



Copy this code and paste it in your HTML
  1. <SCRIPT LANGUAGE="JavaScript">
  2. <!-- Begin
  3. function checkAll(field)
  4. {
  5. for (i = 0; i < field.length; i++)
  6. field[i].checked = true ;
  7. }
  8.  
  9. function uncheckAll(field)
  10. {
  11. for (i = 0; i < field.length; i++)
  12. field[i].checked = false ;
  13. }
  14. // End -->
  15. </SCRIPT>
  16.  
  17. <form name="myform" action="" method="post">
  18. <b>Your Favorite Scripts & Languages</b><br>
  19. <input type="checkbox" name="list" value="1">Java<br>
  20. <input type="checkbox" name="list" value="2">Javascript<br>
  21. <input type="checkbox" name="list" value="3">Active Server Pages<br>
  22. <input type="checkbox" name="list" value="4">HTML<br>
  23. <input type="checkbox" name="list" value="5">SQL<br>
  24.  
  25. <input type="button" name="CheckAll" value="Check All"
  26. onClick="checkAll(document.myform.list)">
  27. <input type="button" name="UnCheckAll" value="Uncheck All"
  28. onClick="uncheckAll(document.myform.list)">
  29. <br>
  30. </form>

URL: code.arthipesa.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.