controlled boxes




JavaScript Source Code 3000: Forms: Controlled Boxes







































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








JavaScript Source Code 3000: Forms: Controlled Boxes
Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Apple-s). The script is yours!!!





    





<!-- TWO STEPS TO INSTALL CONTROLLED BOXES:

1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Scott Waichler -->

<! >
<! >

<!-- 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>
</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->

<BODY>

<center>
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>
</center>



<!-- Script Size: 1.78 KB -->










Wyszukiwarka

Podobne podstrony:
control structures continue
12 control statements
02 ZELIO CONTROL?TALOGUE
Test di controllo
mikrotik bandwidth control
co ControlPortC64
01 52 Check control module 01
2001 01 Know How Commandline Control of Babelfish Translation Service
Causes and control of filamentous growth in aerobic granular sludge sequencing batch reactors
plan project configuration change control?F019DF
05b E65 Remote Control Services
ControlFactory
noise control
Wdrozenie systemu controllingu w firmie Lumag

więcej podobnych podstron