Fought with a bunch of examples and, being still new to jQuery/Javascript, cannot get my code to function (here my my template in gsp):
<table>
<thead>
<tr>
<th><input type="checkbox" name="selectAll" onclick="selectAll(this.checked);"/></th>
</tr>
</thead>
<tbody>
<td>
<td><input type="checkbox" name="domainList" value="${domainInstance.id}"/></td>
</tbody>
<table>
I have the following javascript snippet in my main gsp, that calls the template:
function selectAll(status) {
}
How do I select all checkboxes from the selectAll name?
Since you are using jQuery, you should use an
onclickhandler like below for selectAll.Please note that the above code is going to look into the entire dom for the checkbox with
name=selectAlland set the status of the checkbox withname=domainList.Below is a slightly better version with minor markup change,
jsFiddle DEMO