JSFiddle - React, Tailwind, and code Playground
HTML
<form action="noJavaScript.php" name="theForm" method="post">
<table style="border: 1px solid black" RULES=ALL FRAME=VSIDES>
<th> </th><th>Order #</th><th>Inspector</th><th>Reference #</th><th>Client Name</th><th>Property Address</th><th>City</th><th>State</th><th>Zip</th><th>Inspection Date</th>
<tr><td>
<input type="checkbox" name="selected[]" value="1"/>
<td>test</td>
</tr>
<tr><td>
<input type="checkbox" name="selected[]" value="1"/>
<td>test</td>
</tr>
<tr><td>
<input type="checkbox" name="selected[]" value="1"/>
<td>test</td>
</tr>
<tr><td>
<input type="checkbox" name="selected[]" value="1"/>
<td>test</td>
</tr>
</table>
</form>
<input type="button" id="checkall" value="Check All">
JavaScript
function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
if(!document.forms[FormName])
return;
var objCheckBoxes = document.forms[FormName].elements[FieldName];
if(!objCheckBoxes)
return;
var countCheckBoxes = objCheckBoxes.length;
if(!countCheckBoxes)
objCheckBoxes.checked = CheckValue;
else
// set the check value for all check boxes
for(var i = 0; i < countCheckBoxes; i++)
objCheckBoxes[i].checked = CheckValue;
}
document.getElementById('checkall').onclick = function() {
SetAllCheckBoxes('theForm', 'selected[]', true);
};