I've recently created a data table that includes a checkbox in each row and a dropdown menu in one of the columns. Everything seems to be working fine so far, with a single submit button at the top for user input. The main goal here is to allow users to select checkboxes and dropdown options within rows, and then update the selected rows once submitted.
Here's a snippet of my current code in the View:
<input type="button" id="delete" value="Submit" />
<table id="example" cellpadding="10" width="100%>
<thead>
<tr>
<th><input id="checkAll" type="checkbox" /></th>
<th style="text-align: center; border: 1px solid #eaeaea">Email Address</th>
<th style="text-align: center; border: 1px solid #eaeaea">Select Option</th>
</tr>
</thead>
<tbody>
@foreach (var row in Model)
{
<tr>
<th scope="row"><input type="checkbox" class="checkBox" value="@row.site"></th>
<td class="gfgusername" style="width: 20%; padding: 0px; text-align: center; border-left: 1px solid #eaeaea; border-right: 1px solid #eaeaea">
@row.EmailAddress.Trim()
</td>
<td style="width: 20%; padding: 0px; text-align: center; border-right: 1px solid #eaeaea">
<select class="priorityList" name="priorityList2"><option>Yes</option>
<option>No</option><option>Delete Folder</option></select>
</td>
</tr> }
</tbody>
</table>
<script language="javascript">
$(document).ready(function () {
$("#delete").click(function () {
$('input:checkbox.checkBox').each(function () {
if ($(this).prop('checked')) {
???????????
});
var options = {};
options.url = "/Dashboard/Delete";
options.type = "POST";
options.data = ????;
options.contentType = "application/json";
options.dataType = "json";
options.success = function (msg) {
alert(msg);
};
options.error = function () {
alert("Error while deleting the records!");
};
$.ajax(options);
});
});
</script>
My current question revolves around the concept of saving user responses and passing them through AJAX calls. While I understand how to pass a single value when a user wants to delete something, I'm unsure about how to pass multiple values through ajax, specifically those associated with user-selected checkboxes.