<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="button" name="buttonname" value="Check all" onclick="check(document.formname.checkboxname);">
<input type="button" name="buttonname" value="Uncheck all" onclick="uncheck(document.formname.checkboxname);">
</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="button" name="buttonname" value="Check all" onclick="check(document.formname.checkboxname);">
<input type="button" name="buttonname" value="Uncheck all" onclick="uncheck(document.formname.checkboxname);">
</form>
<script type="text/javascript">
var checkboxes = 5; //The number of checkboxes
function check(form){
for(var i=0;i<checkboxes;i++){
form[i].checked = true;
}
}
function uncheck(form){
for(var i=0;i<checkboxes;i++){
form[i].checked = false;
}
}
</script>
var checkboxes = 5; //The number of checkboxes
function check(form){
for(var i=0;i<checkboxes;i++){
form[i].checked = true;
}
}
function uncheck(form){
for(var i=0;i<checkboxes;i++){
form[i].checked = false;
}
}
</script>
0 comments:
Post a Comment