服务器端数据表中下拉列表的onchange事件
Onchange event of dropdown in server side datatable
这是我的 codeignitor 数据表(http://postimg.org/image/jptkczs8p/)。我正在尝试在状态下拉菜单上创建一个事件 change.all 下拉菜单具有相同的 class.its 看起来下拉菜单根本没有连接到这个 script.m 我缺少 something.please 帮助。
这是我的代码,什么都不做。
$( document ).ready(function() {
$('.status_c').on("change", function() {
//alert("i m working");
var id = this.attr('id');
var value = this.val();
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
//document.getElementById('group_info').style.display='none';
//document.getElementById('library_info').style.display='block';
//document.getElementById("model_body1").innerHTML=xmlhttp.responseText;
alert(xmlhttp.responseText);
}
}
xmlhttp.open("GET","<?php echo base_url();?>records/changestatus?id="+id+"&value="+value+"",true);
xmlhttp.send();
});
});
这是我的控制器
function changestatus()
{
$ids = $this->input->get('id');
$values = $this->input->get('value');
$data = array(
'status' =>$values
);
$this->db->where('id', $ids);
$this->db->update('complaint', $data);
echo "complain updated";
}
这里是服务器端数据表的脚本。
$(document).ready(function()
{
$.fn.dataTable.ext.errMode = 'throw';
var ETable = $('#dataTables-example').dataTable({
"infoEmpty": "No records available",
"sProcessing": "DataTables is currently busy",
"processing": true,
"bSort": false,
"columnDefs": [
{ "width": "20%", "targets": 0 }
],
"serverSide": true,
"sAjaxSource": "<?php echo base_url();?>records/numlistajax",
"aLengthMenu": [[10, 25, 50,100], [10, 25, 50,100]],
"iDisplayLength": 10,
"aaSorting": [[3, 'asc']],
"dom": 'T<"clear">lfrtip',
"bDeferRender": true,
"oLanguage": {
"sInfoFiltered": "",
"sProcessing": "<img style='position:absolute;' src='<?php echo base_url();?>public/img/loading.gif'>"
},
"tableTools": {
"sSwfPath": "assets/swf/copy_csv_xls_pdf.swf"
}
});
});
onchange 事件脚本中的一个小改动
$(document).on("change", ".status_c", function() {
而不是这个
$( document ).ready(function() {
$('.status_c').on("change", function() {
这是我的 codeignitor 数据表(http://postimg.org/image/jptkczs8p/)。我正在尝试在状态下拉菜单上创建一个事件 change.all 下拉菜单具有相同的 class.its 看起来下拉菜单根本没有连接到这个 script.m 我缺少 something.please 帮助。
这是我的代码,什么都不做。
$( document ).ready(function() {
$('.status_c').on("change", function() {
//alert("i m working");
var id = this.attr('id');
var value = this.val();
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
//document.getElementById('group_info').style.display='none';
//document.getElementById('library_info').style.display='block';
//document.getElementById("model_body1").innerHTML=xmlhttp.responseText;
alert(xmlhttp.responseText);
}
}
xmlhttp.open("GET","<?php echo base_url();?>records/changestatus?id="+id+"&value="+value+"",true);
xmlhttp.send();
});
});
这是我的控制器
function changestatus()
{
$ids = $this->input->get('id');
$values = $this->input->get('value');
$data = array(
'status' =>$values
);
$this->db->where('id', $ids);
$this->db->update('complaint', $data);
echo "complain updated";
}
这里是服务器端数据表的脚本。
$(document).ready(function()
{
$.fn.dataTable.ext.errMode = 'throw';
var ETable = $('#dataTables-example').dataTable({
"infoEmpty": "No records available",
"sProcessing": "DataTables is currently busy",
"processing": true,
"bSort": false,
"columnDefs": [
{ "width": "20%", "targets": 0 }
],
"serverSide": true,
"sAjaxSource": "<?php echo base_url();?>records/numlistajax",
"aLengthMenu": [[10, 25, 50,100], [10, 25, 50,100]],
"iDisplayLength": 10,
"aaSorting": [[3, 'asc']],
"dom": 'T<"clear">lfrtip',
"bDeferRender": true,
"oLanguage": {
"sInfoFiltered": "",
"sProcessing": "<img style='position:absolute;' src='<?php echo base_url();?>public/img/loading.gif'>"
},
"tableTools": {
"sSwfPath": "assets/swf/copy_csv_xls_pdf.swf"
}
});
});
onchange 事件脚本中的一个小改动
$(document).on("change", ".status_c", function() {
而不是这个
$( document ).ready(function() {
$('.status_c').on("change", function() {