jQuery DataTables – Row selection using checkboxes and Select extension
For more information, see
https://www.gyrocode.com/projects/jquery-datatables-checkboxes/
HTML
<link rel="stylesheet" href="https://cdn.datatables.net/v/dt/dt-1.10.15/r-2.1.1/se-1.2.2/datatables.min.css">
<script src="https://cdn.datatables.net/v/dt/dt-1.10.15/r-2.1.1/se-1.2.2/datatables.min.js"></script>
<link rel="stylesheet" href="https://gyrocode.github.io/jquery-datatables-checkboxes/1.2.6/css/dataTables.checkboxes.css">
<script src="https://gyrocode.github.io/jquery-datatables-checkboxes/1.2.6/js/dataTables.checkboxes.min.js"></script>
<h3><a href="https://www.gyrocode.com/projects/jquery-datatables-checkboxes/">jQuery DataTables Checkboxes</a></h3>
<a href="https://www.gyrocode.com/projects/jquery-datatables-checkboxes/">See full article on Gyrocode.com</a>
<hr><br>
<form id="frm-example" action="/path/to/your/script.php" method="POST">
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th></th>
<th></th>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Extn</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th></th>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</tfoot>
</table>
<hr>
<p>Press <b>Submit</b> and check console for URL-encoded form data that would be submitted.</p>
<p><button>Submit</button></p>
<p><b>Selected rows data:</b></p>
<pre id="example-console-rows"></pre>
<p><b>Form data as submitted to the server:</b></p>
<pre id="example-console-form"></pre>
</form>
JavaScript
$(document).ready(function() {
var table = $('#example').DataTable({
'ajax': 'https://api.myjson.com/bins/1us28',
'columns': [
{
'data': 0,
'checkboxes': true
},
{
'className': 'control',
'orderable': false,
'data': null,
'defaultContent': ''
},
{ 'data': 1 },
{ 'data': 2 },
{ 'data': 3 },
{ 'data': 4 },
{ 'data': 5 },
{ 'data': 6 }
],
'responsive': {
'details': {
'type': 'column',
'target': 1
}
},
'order': [[2, 'asc']]
});
});