gpt4 book ai didi

javascript - Jquery Datatables 复选框选择附加到输入字段

转载 作者:行者123 更新时间:2023-11-28 04:23:52 25 4
gpt4 key购买 nike

btnSearchName 将打开一个包含搜索结果表的模态框,然后每行都有一个复选框可供选择,然后在单击 btnSubmit 后,模态框将关闭,并且必须将选定的 ssn_or_tin 列放入输入字段中,例如“123” , 645, 936, 743',我已经尝试了很多代码但不起作用,请帮忙

$('#btnSearchName').on("click", function() {
Namestable = $('#NamesDatatable').DataTable({
"processing": true,
'select': {
'style': 'multi'
},
'order': [[1, 'asc']],
dom: "<'row'<'col-sm-6'l><'col-sm-6'f>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-6'i><'col-sm-6'p>>",
"ajax": {
"url": '/Home/GetAllCusname',
"type": "POST",
"datatype": "json",
"data": function (d) {
d.searchParameters = {};
d.searchParameters.name = $('#txtName').val();
}
},
"columns": [
{
defaultContent: '',
className: 'select-checkbox',
'checkboxes': {
'selectRow': true
},
orderable: false
},
{ "data": "ssn_or_tin", "autoWidth": true },
{ "data": "name", "autoWidth": true }
]
});
});

$('#btnSubmit').on("click", function () {
var rows_selected = Namestable.column(0).checkboxes.selected(); //i have not tested this line of code yet if it's working,
maybe there is another way of getting the selected checkbox, maybe by their class if they have the 'selected' class

$.each(rows_selected, function () {
$('#txtSSNTIN').append(
//I don't know what code to put here, it must append the
'ssn_or_tin' values like '123, 953, 673' in the input field with
the id 'txtSSNTIN'
);
});
});

最佳答案

您可以尝试在 DataTable 中使用 Onrowbound。您不必指定这些内容

关于javascript - Jquery Datatables 复选框选择附加到输入字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45233714/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com