Return to Snippet

Revision: 2699
at March 29, 2007 11:28 by davaodude


Initial Code
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;
		}
	}
}

Initial URL


Initial Description
Simple script to toggle (checked or not checked) all checkboxes on the page.

Initial Title
Toggle all form checkboxes

Initial Tags
form

Initial Language
JavaScript