Code to check all boxes by selecting a header checkbox and sendind array of ids of the selected checkboxes :
Creating a Checkbox HTML :
<table id=”table_name”>
<thead>
<tr>
<th><input type=’checkbox’ id=”check_all”></th>
</tr>
</thead>
<tbody>
<tr> <td><input type=”checkbox” name=”ids[]” value=”‘.$t_value[‘task_id’].'”></td> </tr>
</tbody>
</table>
Javascript code to select all checkboxes :
$( document ).on(“click”, “#check_all”,function() {
var checkedStatus = this.checked;
$(‘#table_name tbody tr’).find(‘td:first :checkbox’).each(function () {
$(this).prop(‘checked’, checkedStatus);
});
});
Getting array of ids of checkboxes selected :
$( document ).on(“click”, “#button_id”,function() {
var ids_arr = [];
$(“[name=’ids[]’]:checked”).each(function() {
ids_arr.push(this.value);
});
});
This ids_arr array you are getting is the array of ids checked/ selected. You have to pass this array to the next page through ajax where function or database queries to do with the selected ids is written.
To see How to send data on next page or same page through Ajax , CLICK HERE
Hope you like the post………Please Comment …..!!!!!!!