JSFiddle - React, Tailwind, and code Playground
HTML
<form action="" method="post" onSubmit="return checkTheBox() " name="checkboxform">
<input type='checkbox' name='checkid[]' value=''/>
<input type='checkbox' name='checkid[]' value=''/>
<input type='checkbox' name='checkid[]' value=''/>
<input type='checkbox' name='checkid[]' value=''/>
</form>
<td><a href='javascript:void(0);' onClick="javascript:checkAll('checkboxform', true);"><b>Check All</b></a> |
<a href='javascript:void(0);' onClick="javascript:checkAll('checkboxform', false);"><b>UnCheck All</b></a></td>
JavaScript
function checkAll(formname, checktoggle)
{
var checkboxes = new Array();
checkboxes = document[formname].getElementsByTagName('input');
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].type === 'checkbox') {
checkboxes[i].checked = checktoggle;
}
}
}