varo_name;varuserUrl= "http://127.0.0.1:8000";
$(function() {
initUser();
$('#dri_grid').datagrid('load', userUrl);
$("#dri_tools_add").click(function() {
$("#n_name").val("");
$("#n_time").val("");vara=document.getElementById('driver_add');
a.href= "javascript:driver_adddd()";
$("#adduser").show();
});
$("#dri_tools_edit").click(function() {varrow=$("#dri_grid").datagrid('getSelected');if(row){varname=row.name;
o_name=name;vartime=row.signup_date;
$("#n_name").val(name);
$("#n_time").val(time);vara=document.getElementById('driver_add');
a.href= "javascript:driver_editdd()";
$("adduser").show();
}else{
alert("please select");
}
$("#adduser").show();
});
$("#dri_tools_del").click(function() {varrow=$('#dri_grid').datagrid('getSelected');if(row) {if(confirm("really delete?")){vart_name=row.name;vardatas={
name: t_name
};vardriver_delurl="http://127.0.0.1:8000/DelUser";
$.post(driver_delurl, datas,function(v) {if(v.status=="true") {
$("#dri_grid").datagrid("reload");
alert("success");
}else{
alert("error");
}
});
}
}else{
alert("please select");
}
});
});functiondriver_adddd(){varn_name=$("#n_name").val();varn_time=$("#n_time").val();varuserdata={
name: n_name,
time: n_time
};vardriver_addurl="http://127.0.0.1:8000/AddUser";
$.post(driver_addurl, userdata,function(s) {if(s.status== "true") {
$("#dri_grid").datagrid("reload");
alert('新增成功');
}else{
alert(s.result);
}
});
}functiondriver_editdd(){varn_name=$("#n_name").val();varn_time=$("#n_time").val();varuserdata={
o_name:o_name,
name: n_name,
time: n_time
};vardriver_addurl="http://127.0.0.1:8000/EditUser";
$.post(driver_addurl, userdata,function(s) {if(s.status== "true") {
$("#dri_grid").datagrid("reload");
alert('更新成功');
}else{
alert(s.result);
}
});
}functioninitUser() {
$('#dri_grid').datagrid({
border:false,
fit:true,
singleSelect:true,
method:'get',
pagination:true,
striped:true,
pageSize:20,
onBeforeLoad:function() {
},
columns: [
[{
field:'name',
title:'t_name',
width:'8%',
align:'center'}, {
field:'signup_date',
title:'t_signup_date',
width:'14%',
align:'center'}
]
],
onLoadSuccess:function(data) {
}
});
}
新增
修改
删除
*
姓名:
注册时间: