我在side jquery自动完成功能中调用javascript函数。 b在调用该函数后,我无法从自动完成列表中选择数据。
javascript函数根据自动完成功能填充其他字段中的数据:
function info() {
var txtAddresstext = document.getElementById(txtAddress);
var ss = document.getElementById(hdnInfo);
var ddlInfoLocation = document.getElementById(ddlrInfoLoc);
var str = ss.value;
var arr = str.split("~");
for (var i = 0; i < arr.length; i++) {
txt.text = arr[10];
ddlInfoLocation.selectedIndex = 0;
ddlInfoLocation.options[0].text = arr[0];
txtAddresstext.value = arr[4];
txtAddresstext.value=txtAddresstext.value.replace('undefined', '');
}
}
我的自动完成功能:
<script type="text/javascript">
function Origin(sender, args) {
$(function () {
$("#<%=txtInfo.ClientID %>").autocomplete({
source: function (request, response) {
$.ajax({
url: '<%=ResolveUrl("~/Webservice.asmx/Get") %>',
data: "{ 'prefix': '" + request.term + "'}",
dataType: "json",
type: "POST",
async: false,
mustMatch: true,
contentType: "application/json; charset=utf-8",
success: function (data) {
response($.map(data.d, function (item) {
return {
label: item.split('-')[0],
val: item.split('-')[1]
}
}))
},
error: function (response) {
},
failure: function (response) {
}
});
},
select: function (e, i) {
$("#<%=hdnInfo.ClientID %>").val(i.item.val);
info1()
},
minLength: 0
}).bind('focus', function () { $(this).autocomplete("search"); });
});
}
</script>