When we have multiple check box to select then we need to check all these one by one it will take more time to check all so by using jsscript we can check and unchecked all check box on a single click. In the below script can check and uncheck all check box on a click
<form id="ItemBox">
<table >
<tr>
<td>
<input type="checkbox" name="checkAllCheckBox" id="checkAllCheckBox" onclick="checkedAll();">
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="book" id="book" value="Item 1">Item 1
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="book" id="book" value="Item 2">Item 2
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="book" id="book" value="Item 3">Item 3
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="book" id="book" value="Item 4">Item 4
</td>
</tr>
</table>
</form>
checked = false;
function checkedAll ()
{
if (checked == false)
{
checked = true
}
else
{
checked = false
}
for (var i = 0; i < document.getElementById("ItemBox").elements.length; i++)
{
document.getElementById("ItemBox").elements[i].checked = checked;
}
}
0 Comment(s)