»
EnglishFrenchVietnamese

Print - Checkbox Changer - JavaScriptBank.com

Full version: jsB@nk » Form » Checkbox » Checkbox Changer
URL: http://www.javascriptbank.com/checkbox-changer.html

Checkbox Changer © JavaScriptBank.comTakes a series of known named checkboxes and checks or uncheck them all at once. It can even change each checkbox to the opposite checked or not checked value. Clever for loops!

Full version: jsB@nk » Form » Checkbox » Checkbox Changer
URL: http://www.javascriptbank.com/checkbox-changer.html



JavaScript
<SCRIPT LANGUAGE="JavaScript"><!-- Beginfunction checkAll() {for (var j = 1; j <= 14; j++) {box = eval("document.checkboxform.C" + j); if (box.checked == false) box.checked = true;   }}function uncheckAll() {for (var j = 1; j <= 14; j++) {box = eval("document.checkboxform.C" + j); if (box.checked == true) box.checked = false;   }}function switchAll() {for (var j = 1; j <= 14; j++) {box = eval("document.checkboxform.C" + j); box.checked = !box.checked;   }}//  End --></script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<form name=checkboxform><input type=checkbox name=C1 checked value="ON">C1<br><input type=checkbox name=C2 checked value="ON">C2<br><input type=checkbox name=C3 checked value="ON">C3<br><input type=checkbox name=C4 checked value="ON">C4<br><input type=checkbox name=C5 checked value="ON">C5<br><input type=checkbox name=C6 checked value="ON">C6<br><input type=checkbox name=C7 checked value="ON">C7<br><input type=checkbox name=C8 checked value="ON">C8<br><input type=checkbox name=C9 checked value="ON">C9<br><input type=checkbox name=C10 checked value="ON">C10<br><input type=checkbox name=C11 checked value="ON">C11<br><input type=checkbox name=C12 checked value="ON">C12<br><input type=checkbox name=C13 checked value="ON">C13<br><input type=checkbox name=C14 checked value="ON">C14<br><br><input type=button value="Check All" onClick="checkAll()"><br><input type=button value="Uncheck All" onClick="uncheckAll()"><br><input type=button value="Switch All" onClick="switchAll()"><br></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->