問題描述
我正在使用 jquery 數(shù)據(jù)表列出我的內(nèi)容,其中有復(fù)選框選擇和選定的內(nèi)容發(fā)布數(shù)據(jù),但在提交的表單中僅發(fā)送當(dāng)前頁面數(shù)據(jù).
I am using jquery data table for listing my content which have checkbox selection and selected content post the data but in submitted form only current page data sent.
我的數(shù)據(jù)表代碼是:
$('#select').dataTable( {
"order": [[ 2, "desc" ]],
"lengthMenu": [[50, -1], [50, "All"]],
"columnDefs": [
{ orderable: false, targets: [0, 1, 3, 5] },
{ "width": "20px", "targets": [0, 1] },
{ "width": "80px", "targets": [5] }
],
});
當(dāng)我點擊提交時,它只提交當(dāng)前頁面值的復(fù)選框數(shù)組.
When I click on submit, it only submit the array of checkboxes for the current page values.
我已經(jīng)提到了這個鏈接 帶有選中復(fù)選框的分頁.復(fù)選框僅適用于當(dāng)前分頁頁面.jQuery 數(shù)據(jù)表,但那里提供的帶有鏈接和鏈接的解決方案不起作用.
I have referred this link already Pagination with selected check boxes. Checkboxes will only work on current pagination page. jQuery datatables but solution provided overthere with link and link is not working.
推薦答案
您可以使用以下代碼獲取所有選中的復(fù)選框值,這可能對您有所幫助
you can get all the selected check box values using following code this might be helpful for you
var myArray = [];
var id = "";
var oTable = $("#example").dataTable();
$(".class1:checked", oTable.fnGetNodes()).each(function() {
if (id != "") {
id = id + "," + $(this).val();
} else {
id = $(this).val();
}
});
這篇關(guān)于復(fù)選框僅適用于 jQuery 數(shù)據(jù)表中的當(dāng)前分頁頁面的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!