我对自动填充文本框有问题。我有2个自动填充文本框说客户和客户部门。我想使用从客户自动填充文本框获取的值填写客户部门自动填充文本框。我以下面的格式从数据库中获取数据。
[
{"id":"001","value":"WOVEN TOPS","value1":"RIVER"},
{"id":"001","value":"DRESSES & ONESIES","value1":"URBAN"},
{"id":"001","value":"SOFT WOVEN","value1":"WAREHOUS"}
]
请帮助实现这一目标。
答案 0 :(得分:0)
试试这个
`
$('.AutoCompleteField').autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "ajax.aspx/GetList",
data: "{'term':'" + request.term + "'}",
dataType: "json",
async: true,
success: function (data) { response(data.d); },
error: function (result) { alert("When it goes wrong"); }
});
},
minLength: 2,
focus: function (event, ui) { $('.tbOne').text(ui.item.value); $('.tbTwo').val(ui.item.value1); },
select: function (event, ui){ $('.tbOne').text(ui.item.value); $('.tbTwo').val(ui.item.value1); }
});`