1<script language="JavaScript">
2function toggle(source) {
3 checkboxes = document.getElementsByName('foo');
4 for(var i=0, n=checkboxes.length;i<n;i++) {
5 checkboxes[i].checked = source.checked;
6 }
7}
8</script>
9
10<input type="checkbox" onClick="toggle(this)" /> Toggle All<br/>
11
12<input type="checkbox" name="foo" value="bar1"> Bar 1<br/>
13<input type="checkbox" name="foo" value="bar2"> Bar 2<br/>
14<input type="checkbox" name="foo" value="bar3"> Bar 3<br/>
15<input type="checkbox" name="foo" value="bar4"> Bar 4<br/>
16
1<script language="JavaScript">
2function toggle(source) {
3 checkboxes = document.getElementsByName('foo');
4 for(var checkbox in checkboxes)
5 checkbox.checked = source.checked;
6}
7</script>
8
9<input type="checkbox" onClick="toggle(this)" /> Toggle All<br/>
10
11<input type="checkbox" name="foo" value="bar1"> Bar 1<br/>
12<input type="checkbox" name="foo" value="bar2"> Bar 2<br/>
13<input type="checkbox" name="foo" value="bar3"> Bar 3<br/>
14<input type="checkbox" name="foo" value="bar4"> Bar 4<br/>
15
1function toggle(source) {
2 checkboxes = document.getElementsByName('foo');
3 for(var i=0, n=checkboxes.length;i<n;i++) {
4 checkboxes[i].checked = source.checked;
5 }
6}
7