I have a asp.net gridview page and I've added checkbox column to it. I am using JavaScript to select multiple checkboxes at once if the row values are similar. Now I want to update my database row value to '1' when I select the checkbox in the gridview. Can you please help me to write the logic?
I tired few logics but it is not working and I am getting error
$(document).ready(function() {
// Function to handle checkbox click event
function handleCheckboxClick() {
var invNumber = $(this).val();
var isChecked = $(this).prop('checked');
var checkboxes = $('input[type="checkbox"][value="' + invNumber + '"]');
checkboxes.prop('checked', isChecked);
}
// Function to handle "Select All" checkbox click event
function handleSelectAllClick() {
var isChecked = $(this).prop('checked');
$('input[type="checkbox"][name="invoice"]').prop('checked', isChecked);
}
// Attach event handlers to checkboxes
$(document).on('click', 'input[type="checkbox"][name="inv"]', handleCheckboxClick);
$(document).on('click', 'input[type="checkbox"][name="selectAll"]', handleSelectAllClick);
});
Aucun commentaire:
Enregistrer un commentaire