/ Published in: JavaScript
Simple script to toggle (checked or not checked) all checkboxes on the page.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function toggleCheckboxes() { // written by Daniel P 3/21/07 // toggle all checkboxes found on the page var inputlist = document.getElementsByTagName("input"); for (i = 0; i < inputlist.length; i++) { if ( inputlist[i].getAttribute("type") == 'checkbox' ) { // look only at input elements that are checkboxes if (inputlist[i].checked) inputlist[i].checked = false else inputlist[i].checked = true; } } }