0
我试图用jQuery自动完成搜索客户数据。我有以下情况。jQuery自动完成选择标签和值,并只显示标签
客户姓名和手机号码应显示为列表选择和选择,我只能将客户名称显示为自动填充文本框。
我试过下面的代码,但它不会工作。
$("#txtServiceCustSearch").autocomplete(
{
source: function (request, response) {
$.ajax({
url: '<%=ResolveUrl("~/AutoComplete.asmx/GetServiceCustomer") %>',
data: "{ 'prefix': '" + request.term + "'}",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (data) {
$("[id*='grvHistory']").empty();
response($.map(data.d, function (item) {
return {
label: item.split('$')[0],
val: item.split('$')[1],
val1: item.split('$')[2],
val2: item.split('$')[3],
val3: item.split('$')[4],
val4: item.split('$')[5],
val5: item.split('$')[6],
val6: item.split('$')[7],
val7: item.split('$')[8]
}
}))
},
error: function (response) {
alert(response.responseText);
},
failure: function (response) {
alert(response.responseText);
}
});
},
select: function (e, i) {
$("#txtServiceAddress").val(i.item.val);
$("#txtPinCode").val(i.item.val1);
$("#txtServiceContactNo").val(i.item.val2);
$("#txtLandmark").val(i.item.val3);
$("#txtEmailID").val(i.item.val4);
$("#txtServiceDOB").val(i.item.val5);
$("#txtServiceMobileNo").val(i.item.val6);
$("#txtServiceCustSearch").val(i.item.val7); },
close: function (e, i) {
},
minLength: 3
});