Controlled Boxes

[Total: 0    Average: 0/5]

This script allows checkboxes to check and uncheck based on the selection in another checkbox.

Head Code:

<!-- Begin
function checkChoice(field, i) {
if (i == 0) { // "All" checkbox selected.
if (field[0].checked == true) {
for (i = 1; i < field.length; i++)
field[i].checked = false;
else  {  // A checkbox other than "Any" selected.
if (field[i].checked == true) {
field[0].checked = false;
//  End -->

Body Code:

Please select your favorite class(es):
<form name=pickform>
<input type=checkbox name=classes value="*" onclick="checkChoice(document.pickform.classes, 0)" checked>All
<input type=checkbox name=classes value="science" onclick="checkChoice(document.pickform.classes, 1)">Science
<input type=checkbox name=classes value="math" onclick="checkChoice(document.pickform.classes, 2)">Math
<input type=checkbox name=classes value="english" onclick="checkChoice(document.pickform.classes, 3)">English
<input type=checkbox name=classes value="history" onclick="checkChoice(document.pickform.classes, 4)">Histroy
<input type=checkbox name=classes value="other" onclick="checkChoice(document.pickform.classes, 5)">Other

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *