Script Categories













Forms >>> Controlled Boxes.

This script allows checkboxes to check and uncheck based on the selection in another checkbox. If the ALL box is checked, all the other choices go unchecked. If another choice is checked, then the ALL box goes unchecked. Useful when constructing search forms, surveys, and more!

Please select your favorite class(es):
All
Science
Math
English
Histroy
Other

Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- 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 -->
</script>
Please select your favorite class(es):
<form name=pickform>
<table>
<tr><td>
<input type=checkbox name=classes value="*" onclick="checkChoice(document.pickform.classes, 0)" checked>All
<br>
<input type=checkbox name=classes value="science" onclick="checkChoice(document.pickform.classes, 1)">Science
<br>
<input type=checkbox name=classes value="math" onclick="checkChoice(document.pickform.classes, 2)">Math
<br>
<input type=checkbox name=classes value="english" onclick="checkChoice(document.pickform.classes, 3)">English
<br>
<input type=checkbox name=classes value="history" onclick="checkChoice(document.pickform.classes, 4)">Histroy
<br>
<input type=checkbox name=classes value="other" onclick="checkChoice(document.pickform.classes, 5)">Other
</td></tr>
</table>
</form>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).




©