I'm using the jquery datatables plugin.
I have just a straight html table layout for it.
<table class="display" id="contactsTable">
<thead>
<tr>
<th>Id</th>
<th>Email</th>
<th>Name</th>
<th>Phone</th>
<th>City</th>
<th>State</th>
<th>Arrival</th>
<th>Departure</th>
<th>Inserted</th>
<th>Check</th>
</tr>
</thead>
<tbody>
<tr>
<td>301</td>
<td>email address</td>
<td>Test</td>
<td></td>
<td></td>
<td></td>
<td>July 14 2011</td>
<td>July 23 2011</td>
<td>April 12 2011 07:05</td>
<td><input type="checkbox" name="selected[]" value="301" class="chkbox"/></td>
</tr>
<tr>
<td>300</td>
<td>email</td>
<td>Test</td>
<td></td>
<td></td>
<td></td>
<td>September 02 2011</td>
<td>September 10 2011</td>
<td>April 11 2011 12:01</td>
<td><input type="checkbox" name="selected[]" value="300" class="chkbox"/></td>
</tr>
Here is my code for submit (just temp).
<input id="submitButton" type="submit" value="Submit" onclick="test()" />
And my javascript to map the checkboxes to an array.
function test() {
var values = $('input:checkbox:checked.chkbox').map(function () {
return this.value;
}).get();
console.log(values);
}
Here is the datatables code
$(document).ready(function() {
var selected;
var selectedOutput = '#selectedOutput';
var template = 'selectedTemplate';
var submitButton = '#submitButton'
var dTable = $('#contactsTable').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bPaginate": true,
"bLengthChange": true,
"bFilter": true,
"bSort": false,
"bInfo": true,
"bAutoWidth": false,
"bProcessing": true,
"aoColumns": [
{"bVisible": false }, //keep the id invisble
null,
null,
null,
null,
null,
null,
null,
null,
null
]
});
The problem is, I can't do a checkbox selection across a page. The table has mutiple pages to it. If I click submit, it only submits the array of checkboxes for the current page I am on.
I hope this is clear enough. I'm not sure what is happening. Thanks for any help.