Click here to Skip to main content
15,885,366 members

Comments by Member 13998042 (Top 18 by date)

Member 13998042 9-Apr-23 8:15am View    
$(document).ready(function () {
$('#example').DataTable();
$('#btnSubmit').click(function () {
var ids = [];
$('#example tbody input[name="chkSelect"]:checked').each(function () {
ids.push($(this).attr('id'));
});
console.log(ids);
$.ajax({
type: "POST",
dataType: "JSON",
url: "/HRValidation/AssignToHR",
data: { ids: ids },
success: function (data) {
// Handle the response from the controller
}
});
});
});

This is my script it returns the value as array but it is not hitting the controller it defaults return 200

[HttpPost]
public void AssignToHR(List<string> ids)
{
foreach (var id in ids)
{
// Do something with the ID
}
//return Json(new { success = true });
}
Member 13998042 4-Apr-23 14:09pm View    
Hi Sir, I understand this is good for limit or knows number of checkboxes, But my datatabl will or may return more records including checkboxes and i need to capture it dynamically. also i need to pass it in array because in controller i am using foreach loop to modify record in db.
Member 13998042 6-Feb-23 7:17am View    
Dear Richard,

The reason i am asking to change the value of the check box is because when i move back to the previous page the if the checkbox is checked , When updating the value it goes back to 0 again instead of 1.
Member 13998042 22-Dec-22 23:55pm View    
hi jeanFerre unfortunately the code is too big to post it in here. thats why i have created and shared a sample project via github. Can you please take a look at it and help me . the link is : https://github.com/dev-gurukaushik/ddandcheckbox
Member 13998042 14-Dec-22 7:38am View    
i am using datafirst approach so when i scaffold db to model in c# it automatically get's this datatype. also new to entity framework. Please suggest some guidence.