首先,它不是关于过滤(搜索)下拉列表。
我正在使用Datatables:我的列中有一个下拉列表,我希望当我更改或从中选择任何选项时...它应该传递给它resp值
$(document).ready(function () {
dt = $('#example').DataTable({
"pagingType": "full_numbers",
"scrollY": "440px",
"scrollX": "100%",
"scrollCollapse": true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/server_processing.php",
"deferRender": true,
"aoColumns": [{
className: "center",
"class": "details-control",
"orderable": false,
"data": null,
"defaultContent": "",
},
{ className: "center", },
{ className: "center", },
{ className: "center", },
{ className: "center", },
{ className: "center", },
{ className: "center", },
],
"columnDefs": [{
"aTargets": [7],
"fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
$(nTd).css('text-align', 'center');
},
"mData": null,
"mRender": function (data, type, full) {
return '<td><select id="dynamic_select" name="dynamic_select">\n\
<option id="0" value="">Select</option/>\n\
<option id="1" value="test.php">1</option/>\n\
<option id="2" value="test2.php">13</option/>\n\
<option id="31" value="test3.php">12</option/>\n\
</select></td>';
}
}]
});
$('select[name=dynamic_select]').on('change', function () {
var attvalue = $(this).children(":selected").attr("id");
var mainval = $(this).val();
var url = mainval;
if ($(this).children(":selected").attr("id") == 0) {
} else if ($(this).children(":selected").attr("id") == 1) {
window.open(url, "_self");
} else {
window.open(url, "_self");
}
return false;
});
});
下面是我的HTML
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th></th>
<th>First name</th>
<th>Last name</th>
<th>Position</th>
<th>Office</th>
<th>Start date</th>
<th>Salary</th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th>First name</th>
<th>Last name</th>
<th>Position</th>
<th>Office</th>
<th>Start date</th>
<th>Salary</th>
<th></th>
</tr>
</tfoot>
</table>
一切正常......只是改变了选择值..我需要它应该去 resp。网址及其分配。 id
我也可以为每一行定义一个唯一的ID(或我的数据库主ID)吗?
注意:如果我将jquery放在我的简单PHP中,那么它的工作原理......但不知道为什么它不在数据表中工作
请帮帮我