I would like to submit form data when clicking a check box within a list. Currently I am using the onclick event which does not work because it sends a get request and I need it to send a post request.
How can I post the two parameters to my controller method from within the loop.
EDIT From the comments below I need to use AJAX as I was intending to remain on the same page. I incorrectly thought a post request would do that. If someone is willing to point me in the right direction with AJAX that would be appreciated.
Here is the code:
@for (var i = 0; i < Model.Count(); i++)
{
<tr>
<td>
@Html.DisplayFor(modelItem => modelItem[i].InvoiceID)
</td>
<td>
@Html.DisplayFor(modelItem => modelItem[i].Description)
</td>
<td>
@Html.DisplayFor(modelItem => modelItem[i].InvoiceDate)
</td>
<td>
@Html.DisplayFor(modelItem => modelItem[i].DueDate)
</td>
<td>
<input asp-for="@Model[i].Paid" onclick="location.href='@Url.Action("UpdatePaidStatus", "Billing", new { invoiceID = Model[i].InvoiceID, paid = Model[i].Paid })'" />
</td>
</tr>
}