我之前的问题并不清楚,所以我正在更新一些细节。问题是当你去www.gigmama.com时,我有一个城市,状态表单输入框附加到JQuery autosuggest“插件”。当你开始在波特兰打字时,它应该获取以该名称开头的任何城市,州组合。它确实没问题。但是,我似乎无法从列表中选择俄勒冈州波特兰市。当我开始将鼠标悬停在它上面时,它会立即进入列表的底部。
这是一些代码。
$( "#citystate" ).autocomplete({
minLength: 3,
//source: "clientquery.php"
source: function(req, add){
//pass request to server
$.getJSON("clientquery1.php", req, function(data) {
//create array for response objects
var suggestions = [];
//process response
$.each(data, function(i, val){
//suggestions.push(val.label);
suggestions.push(
{
label : val.label,
value : val.value
}
);
});
//pass array to callback
add(suggestions);
});
},
select: function( event, ui ) {
////alert( ui.item ? "Selected: " + ui.item.value + " aka " + ui.item.label : "Nothing selected, input was " + this.value );
loc = ui.item.value.indexOf(",");
city = ui.item.value.substr(0,loc);
state = ui.item.value.substr(loc+2, ui.item.value.length);
//alert("city = " + city + " and state = " + state);
$("#city").val(city);
$("#state").val(state);
}
});