如何在自动完成jquery上填充文本框 [英] how to populate textbox on autocomplete jquery
本文介绍了如何在自动完成jquery上填充文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
i有asp.net网站,
我有一个带自动完成jquery功能的文本框,
现在
i希望根据自动填充文本框的选择填充其他文本框。
jquery代码:
Hi guys,
i have asp.net website,
where i have a textbox with autocomplete jquery function,
now
i want to populate other textboxes based on the selection of autocomplete textbox.
jquery code:
<script type="text/javascript">
$(document).ready(function () {
$("#<%=txtSearch.ClientID %>").autocomplete({
source: function (request, response) {
$.ajax({
url: '<%=ResolveUrl("~/Service.asmx/GetCustomers") %>',
data: "{ 'prefix': '" + request.term + "'}",
dataType: "json",
type: "POST",
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) {
alert(response.responseText);
},
failure: function (response) {
alert(response.responseText);
}
});
},
select: function (e, i) {
$("#<%=hfCustomerId.ClientID %>").val(i.item.val);
},
minLength: 1
});
});
</script>
任何人都可以帮助我,如何根据自动填充文本框填充其他文本框。 />
谢谢
can anyone plz help me, how to populate other textboxes based on autocomplete textbox.
Thanks
推荐答案
(文件).ready(function(){
(document).ready(function () {
(#<%= txtSearch.ClientID%>)。autocomplete({
source:function(request,response){
("#<%=txtSearch.ClientID %>").autocomplete({ source: function (request, response) {
.ajax({
url:'<%= ResolveUrl(〜/ Service.asmx / GetCustomers)%>',
data:{'prefix':'+ request.term +'} ,
dataType:json,
类型:POST,
contentType:application / json; charset = utf-8,
成功:函数(数据) {
回复(
.ajax({ url: '<%=ResolveUrl("~/Service.asmx/GetCustomers") %>', data: "{ 'prefix': '" + request.term + "'}", dataType: "json", type: "POST", contentType: "application/json; charset=utf-8", success: function (data) { response(
这篇关于如何在自动完成jquery上填充文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文