Select/Deselect all via JS

Better lightweight code to toggle the status.
JavaScript


function checkAll(formObj, is_checked) {
	for (var i=0;i < formObj.length;i++) {
		fldObj = formObj.elements[i];
		if (fldObj.type == 'checkbox') {
			fldObj.checked = is_checked;
		}
	}
}
is_checked_all = false;
function toggleCheckAll(formObj) {
	is_checked_all = !is_checked_all;
	checkAll(formObj, is_checked_all);
}

CALLING THE FUNCTION

toggleCheckAll(document._DominoForm);return false;

Written by Frank Joseph Brefere III

Posted by fbrefere001 on Saturday March 8, 2008