我使用jquery.autocomplete.js用於自動完成文本框。
如何修復jQuery中的文本框自動完成?
我得到按鍵事件的所有位置記錄。
按鍵事件我傳遞了位置文本框的文本值。
for eq。我寫文本「Lo」,那麼每次從SQL數據庫獲得新建議時,它都會獲得以「Lo」開頭的所有記錄。
我的問題是。我在文本框下看到了兩個,三個或更多的列表框作爲建議.. 我寫了.unautocomplete()方法來刪除每個按鍵事件中的以前的建議列表。 如何解決從文本框以前unautocomplte名單..
在我的自動完成我看到自動完成建議列表中顯示一個以上的建議列表.. 如何解決這個問題..
下面我寫我的代碼。
<script>
$('#<%= txtLocation.ClientID %>').onkeypress(function() {
if ($('#<%= txtLocation.ClientID %>').val().length >= 1) {
GetCitiesLikeList($('#<%= txtLocation.ClientID %>').val());
}
});
function GetCitiesLikeList(objcity) {
if (objcity != null && objcity != "") {
$.ajax({
type: "POST",
url: "http://www.myweburl.com/webservices.asmx/GetCitiesLikeList",
data: "{ City : '" + objcity + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
if (msg.d != null && msg.d != "") {
cities = msg.d.split(",");
$(".location").autocomplete(cities, {
matchContains: true,
minChars: 0
});
}
else
$(".location").unautocomplete();
},
error: function(xhr, ajaxOptions, thrownError) {return false;}
});
}
else
$(".location").unautocomplete();
}
</script>
看看這個圖片是什麼問題,我autocompleter建議名單是怎麼回事。
給我這個解決方案。
-Thanks
ABHI
我使用http://docs.jquery.com/Plugins/autocomplete插件。 – 2011-04-13 10:43:44