I have some dynamically generated table, each looking somewhat like this, with a dynamic ID
<table class="innerDatTable" id="dynamically-generated'>
<caption><h2>Project #</h2></caption>
<thead>
<tr>
<th></th>
<th>SubProject Name</th>
<th>Date Completed</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox" /></td>
<td><span>SubProjectName</span></td>
<td><span>Date</span></td>
</tr>
</tbody>
</table>
When a user click on any of the checkboxes within a table, all the other checkboxes that are not inside this table should be disabled (so they can only select subprojects from the same project). Vice versa, if the user unchecks all the boxes inside a table, all the checkboxes become available again. I tried something like this...
if ($('table input:checked').length > 0) {
checked = $(this).prop('checked');
($('table input[type=checkbox]').attr('id').not($(this).attr('id')))
.prop('disabled', checked);
}
The logic here is that if any boxes are checked within the table, disable all the other checkboxes that do not have the same ID as this table (again, the IDs are not known ahead of time). I mainly followed the answer in this question and tried to alter it to my needs, but I'm not able to get the desired effect (or any effect, for that matter).
Do I need to put all the other table IDs in an array, and disable each of them in a loop? Could someone point me in the right direction in terms of syntax, or maybe better logic?