Say I have a table with of clients with multiple checkboxes:
@foreach (var item in Model.Clients)
{
<tr class="@highlightRowClass" data-clientnumber="@item.ClientNumber">
<td>
@Html.CheckboxFor(modelItem => item.Checkbox1)
</td>
<td>
@Html.CheckBoxFor(modelItem => item.CheckBox2)
</td>
</tr>
}
I want to have an ajax call the posts back the array of ids with an object that represents if one or both of the checkboxes are ticked:
var obj = {
CheckBox1Ticked: true,
Checkbox2Ticked: false,
};
pendingChanges[clientId] = obj ;
How would I loop through each table row and populate the array using Jquery?
You can populate the array like this:
checkboxDatais then an array you can pass/interrogate as required: