JavaScript Check All / Uncheck All Boxes


This script will let you check all and uncheck all boxes in a form.



Box one
Box two
Box three
Box four
Box five


Script Source


<The Form >

<form name="myform" action="" method="post">
<input type="checkbox" name="box" value="1">Box one<br>
<input type="checkbox" name="box" value="2">Box two<br>
<input type="checkbox" name="box" value="3">Box three<br>
<input type="checkbox" name="box" value="4">Box four<br>
<input type="checkbox" name="box" value="5">Box five<br>

<input type="button" name="CheckAll" value="Check All"
<input type="button" name="UnCheckAll" value="Uncheck All"


<The JavaScript >

<script type="text/javascript">

function checkBox(field)
for (i = 0; i < field.length; i++)
field[i].checked = true ;

function uncheckBox(field)
for (i = 0; i < field.length; i++)
field[i].checked = false ;
// End -->


Please let me know if this script was helpful to you.