I'm pulling my hair out trying to find a checkbox check-all toggle script that will pass an array of selected to my server side PHP script. I really want a master checkbox that serves as a select-all/deselect-all control.
I've looked at countless examples online, and the closest I can find is one below that doesn't seem to submit anything very useful, the posted data is:
Array ( [all] => on [checkGroup] => fourth [Submit] => Submit )
which doesn't seem very useful when I want to process the results on the server side. I was expecting an array that I could use to build an SQL query.
<script type="text/javascript">
function checkAll(checkname, exby) {
for (i = 0; i < checkname.length; i++)
checkname[i].checked = exby.checked? true:false
}
</script>
<form name="form2" method="post" action="?action=evaluate">
<input type="checkbox" name="all" onClick="checkAll(document.form2.checkGroup,this)">Check/Uncheck All<br>
<input type="checkbox" name="checkGroup" value ="first">First<br>
<input type="checkbox" name="checkGroup" value ="second">Second<br>
<input type="checkbox" name="checkGroup" value ="third">Third<br>
<input type="checkbox" name="checkGroup" value ="fourth">Fourth<br>
<input type="submit" name="Submit" value="Submit" style="height:23px;font-weight:bold;padding-top:0px;">
</form>
Can anyone help me find a suitable script, or help me modify this one?