<form name="formname">
<input type="checkbox" name="checkboxname">Option 1<br>
<input type="checkbox" name="checkboxname">Option 2<br>
<input type="checkbox" name="checkboxname">Option 3<br>
<input type="checkbox" name="checkboxname">Option 4<br>
<input type="checkbox" name="checkboxname">Option 5<br>
<input type="checkbox" name="checkboxname" onclick="checkthem(document.formname.checkboxname);">Controller
</form>
Here is the Javascript:<input type="checkbox" name="checkboxname">Option 1<br>
<input type="checkbox" name="checkboxname">Option 2<br>
<input type="checkbox" name="checkboxname">Option 3<br>
<input type="checkbox" name="checkboxname">Option 4<br>
<input type="checkbox" name="checkboxname">Option 5<br>
<input type="checkbox" name="checkboxname" onclick="checkthem(document.formname.checkboxname);">Controller
</form>
<script type="text/javascript">
var checkboxes = 5; //The number of checkboxes
var controller = checkboxes; //0 if the controller checkbox is the first one, the checkboxes number if it`s the last one
function checkthem(form){
if(form[controller].checked == true){
for(var i=0;i<checkboxes;i++){
form[i].checked = true;
}
}
else{
for(var i=0;i<checkboxes;i++){
form[i].checked = false;
}
}
}
</script>
var checkboxes = 5; //The number of checkboxes
var controller = checkboxes; //0 if the controller checkbox is the first one, the checkboxes number if it`s the last one
function checkthem(form){
if(form[controller].checked == true){
for(var i=0;i<checkboxes;i++){
form[i].checked = true;
}
}
else{
for(var i=0;i<checkboxes;i++){
form[i].checked = false;
}
}
}
</script>
0 comments:
Post a Comment