jquery ajax
jQuery(document).ready(function() {
jQuery('#customer').jqm({ modal: true, trigger: jQuery('#cbutton') });
if (Number != null) {
jQuery.ajax({
type: "POST",
contentType: "application/json",
url: "customer.asmx/JudgeUser",
dataType: 'json',
data: "{ number:'" + Number + "' }",
success: function(jsonStr) {
var jsonObj = eval('(' + jsonStr.d + ')');
if (jsonObj.length == 1) {
jQuery("#name").val(jsonObj[0].Name);
jQuery("#sex").val(jsonObj[0].Sex);
jQuery("#phonenumber").val(jsonObj[0].PhoneNumber);
jQuery("#certype").val(jsonObj[0].CerType);
jQuery("#certificate").val(jsonObj[0].Certificate);
jQuery("#address").val(jsonObj[0].Address);
}
else if (jsonObj.length > 1) {
jQuery.each(jsonObj, function(i, item) {
jQuery('#cutomerTable').append("<tr onclick='getCustomer(this)' onmouseover='showColor(this)'><td align='center' style='display:none'>" + item.ID + "</td><td align='center'>" + item.Name
+ "</td><td align='center'>" + item.Sex + "</td><td align='center'>"
+ item.PhoneNumber + "</td><td align='center'>" + item.Address + "</td></tr>")
});
jQuery('#customer').jqmShow();
}
}
});
}
}
);
function showColor(obj) {
jQuery(obj).hover(
function() {
jQuery(this).addClass("blue");
},
function() {
jQuery(this).removeClass("blue");
}
);
}
function SearchCustomer()
{
jQuery.ajax({
type: "POST",
contentType: "application/json",
url: "customer.asmx/GetCustomerByNameAndAddress",
dataType: 'json',
data: "{ name:'" +jQuery('#sname').val() + "', sex:'"+jQuery('#ssex').val()+"',cer:'"+jQuery('#scer').val()+"',phonenumber:'"+jQuery('#sphonenumber').val()+"',address:'"+jQuery('#saddress').val()+"' }",
success: function(jsonStr) {
var jsonObj = eval('('+jsonStr.d+')');
jQuery('#cutomerTable').remove();
jQuery("#div_customer").append('<table width="100%" id="cutomerTable" border="0" cellpadding="3" cellspacing="0" style="border:1px solid #666;">'
+'<tr>'+
'<th bgcolor="cccccc">姓名</th>'
+'<th bgcolor="cccccc">性别</th>'
+'<th bgcolor="cccccc">电话</th>'
+'<th bgcolor="cccccc">地址</th>'
+'</tr>'
+'</table>');
if(jsonObj.length > 0)
{
jQuery.each(jsonObj,function(i,item){
jQuery('#cutomerTable').append("<tr onclick='getCustomer(this)' onmouseover='showColor(this)'><td align='center' style='display:none'>" + item.ID + "</td><td align='center'>" + item.Name
+ "</td><td align='center'>" + item.Sex + "</td><td align='center'>"
+ item.PhoneNumber + "</td><td align='center'>" + item.Address + "</td></tr>")
})
}
}
});
}
function getCustomer(obj){
jQuery.ajax({
type: "POST",
contentType: "application/json",
url: "customer.asmx/GetCustomerByID",
dataType: 'json',
data: "{ ID:'" + jQuery(obj).children("td:eq(0)").text() + "' }",
success: function(jsonStr) {
var jsonObj = eval('('+jsonStr.d+')');
if(jsonObj.length == 1)
{
jQuery("#name").val(jsonObj[0].Name);
jQuery("#sex").val(jsonObj[0].Sex);
jQuery("#phonenumber").val(jsonObj[0].PhoneNumber);
jQuery("#certype").val(jsonObj[0].CerType);
jQuery("#certificate").val(jsonObj[0].Certificate);
jQuery("#address").val(jsonObj[0].Address);
ID = jsonObj[0].ID;
}
jQuery('#customer').jqmHide();
}
});
}
function button4_onclick() {
SearchCustomer();
jQuery('#customer').jqmShow();
}
function button1_onclick() {
jQuery('#customer').jqmHide();
}
function cbutton_onclick() {
jQuery('#customer .text').val("");
jQuery('#cutomerTable').remove();
jQuery("#div_customer").append('<table width="100%" id="cutomerTable" border="0" cellpadding="3" cellspacing="0" style="border:1px solid #666;">'
+'<tr>'+
'<th bgcolor="cccccc">姓名</th>'
+'<th bgcolor="cccccc">性别</th>'
+'<th bgcolor="cccccc">电话</th>'
+'<th bgcolor="cccccc">地址</th>'
+'</tr>'
+'</table>');
}