function getAjaxList(explorer) { $.get("Community_Dictionary.asp?KeyWords="+explorer, null, function(data){ var dictionaryData = ""; if (data.length>0) { var json = eval('('+data+')'); var jsonLength = json.list.length; dictionaryData = "<div style='margin-bottom:10px;background-color:#d6efac;line-height:28px;padding-left:20px;height:28px'><img src='../image/xz_tb.gif'/><font color=green><b>选择小区</b></font>(如下列表中不存在,点此<a id='create-new-community' href='javascript:void(0)'><font color=red>+新建小区</font></a>)</div><div id='box'>"; for ( var i = 0; i < json.list.length; i++) { var Community_ID = json.list[i].Community_ID; var Community = json.list[i].Community; var Address = json.list[i].Address; if (Address == "null") Address = ""; var Area_ID = json.list[i].Area_ID; dictionaryData = dictionaryData
下载地址http://www.never-online.net/code/neverModules/autocomplete/
简要说明:http://bbs.okajax.com/viewthread.php?tid=1874&page=1
</div>
<div id="dictionaryPage">
<a onclick="$('#showDictionary').hide();">关闭</a>
</div>
</div>$(function() {
$("#create-new-community").click(onCreateNewFloor_Click);
});
function onCreateNewFloor_Click() {
newFloor('newfloors','NewCommunity.asp','新建小区');
return false;
}function newFloor(id,url,title) {
var Community = $("#Community").val();
Community = Community.replace("·", "-");
$.plugins.showDialog("newfloors",title,url + '?Community=' + Community, 350,200);
}function dialog_close() {
$.plugins.closeDialog("newfloors");
}/*-= ajax选择小区 -=*/$(function(){var _ajaxFloorList = function(explorer){
if (explorer != "") {
getAjaxList(explorer)
//getAjaxListPage(explorer, 1)
}
$("#showDictionary").show();
}; //小区选择
var xq_func = function() {
_ajaxFloorList(this.value);
};
$("#Community").bind("propertychange", xq_func).bind("input",xq_func);
})
//ajax select community
function getAjaxList(explorer) {
$.get("Community_Dictionary.asp?KeyWords="+explorer,
null,
function(data){
var dictionaryData = "";
if (data.length>0) {
var json = eval('('+data+')');
var jsonLength = json.list.length;
dictionaryData = "<div style='margin-bottom:10px;background-color:#d6efac;line-height:28px;padding-left:20px;height:28px'><img src='../image/xz_tb.gif'/><font color=green><b>选择小区</b></font>(如下列表中不存在,点此<a id='create-new-community' href='javascript:void(0)'><font color=red>+新建小区</font></a>)</div><div id='box'>";
for ( var i = 0; i < json.list.length; i++) {
var Community_ID = json.list[i].Community_ID;
var Community = json.list[i].Community;
var Address = json.list[i].Address;
if (Address == "null")
Address = "";
var Area_ID = json.list[i].Area_ID;
dictionaryData = dictionaryData
+ "<div style='height:22px;line-height:29px;padding-left:40px;overflow:hidden;'><img src='../image/sjy_x.gif'/><a class='item' href=\"javascript:;\" onClick=\"javascript:selectFloor("
+ "'" + Community_ID + "'," + "'" + Community
+ "','" + Address + "','" + Area_ID + "');\"><font color=#ff6200>"
+ Community + "</font></a><font color=#565e53> " + Address
+ "</font></div>";
}
//dictionaryData += "<a id='create-new-floor' href='javascript:void(0)'>列表中不存在,<span style='color:red;font-size:16px;'>点此</span>新建小区</a>";
} else {
dictionaryData += "<a id='create-new-community' href='javascript:void(0)' style='display:block;margin:6px 0 0 6px;'>列表中不存在,<span style='color:red;font-size:16px;'>点此</span>新建小区</a>";
}
dictionaryData +="</div>"
$("#dictionary").html(dictionaryData);
if($("#box").height()>200){
$("#box").css("height","200px");
$("#box").css("overflow-y","scroll");
}
$("#create-new-community").click(onCreateNewFloor_Click);
}, "text");
}
function selectFloor(Community_ID,Community,Address,Area_ID) {
$("#Community_ID").val(Community_ID);
$("#Community").val(Community);
//$("#Address").val(Address);
//$("#Area_ID").val(Area_ID);
$("#showDictionary").hide();
}