Php 数据表:更改下拉列表
首先,它不是关于过滤搜索下拉列表 我正在使用:在我的一列有下拉列表的地方,当我更改或从中选择任何选项时。。。它应该传递给它相应的值Php 数据表:更改下拉列表,php,mysql,datatables,jquery-datatables,dropdownbox,Php,Mysql,Datatables,Jquery Datatables,Dropdownbox,首先,它不是关于过滤搜索下拉列表 我正在使用:在我的一列有下拉列表的地方,当我更改或从中选择任何选项时。。。它应该传递给它相应的值 $(document).ready(function () { dt = $('#example').DataTable({ "pagingType": "full_numbers", "scrollY": "440px", "scrollX": "100%", "scrollCollapse"
$(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。Url及其响应。身份证
我还可以为每一行定义一个唯一的id或我的数据库主id吗
注意:如果我把上面的jquery放在我的简单PHP中,那么它就可以工作了。。但我不知道为什么它不能在数据表中工作
请帮助我尝试更改此$'select[name=dynamic_-select]'。在'change'上,函数{更改为$document。在'change'上,函数{select[name=dynamic_-select]'{你试过了吗?@Darren:非常感谢+1…我为此奋斗了1个小时..请你简要介绍一下区别..因为我是新来的..还有我如何使每个选择都是唯一的..使用任何唯一的ideach@hindmost…我的第一行首先告诉大家它不是关于筛选搜索下拉列表…意味着我不想筛选…它这是一个带有下拉菜单的额外列嘿,我所做的是在“立即选择”中添加“+full[0]+”它的外观:其中[0]是我的主id,它是唯一的..在更改时我添加了$document。在“更改”中,选择[name=dynamic_select'+full[0]+”,函数{-它的右边?