下拉框提示功能求助! Quote: 引用 2 楼 Return_false 的回复:完全不会,悲剧啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 正解 需要 增加input 的onchange事件 ,就是比如你输入一个"北" , 输入框内容发生变化 ,触发onchange事件 在该事件处理程序中通过ajax获取数据库与"北"相关的城市地址列表,生成下拉列表让你选择 需要使用如Jquery AutoComplete控件,实现较为简单 实现简单么,可是我完全不会js,能不能帮忙写个demo呢,不甚感激 你去下一个 里面都有demo的 也有函数的介绍api手册 对着看就好了 正解 实现简单么,可是我完全不会js,能不能帮忙写个demo呢,不甚感激 ,还有我自己没有数据库,数据也和天气网一样从别处获取。 示例仅供参考<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>autocomplete测试</title><link rel="stylesheet" type="text/css" href="jquery-ui-1.10.4.custom/css/ui-lightness/jquery-ui-1.10.4.custom.min.css" /><style>img{width:30px;height:30px;}</style><script src="jquery-ui-1.10.4.custom/js/jquery-1.10.2.js"></script><script src="jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script></head><body><input type="text" id="autocompleteTest" autocomplete="off" name="q" value="autocomplete测试" onfocus="if(this.value=='autocomplete测试'){this.value='';}" onblur="if(this.value=='') {this.value = 'autocomplete测试';}" class="ui-autocomplete-input"><script type="text/javascript">var json=[{label:"aaa",pictureurl:"http://www.baidu.com/img/bdlogo.gif",url:"http://www.baidu.com"},{label:"bbbbb",pictureurl:"http://i1.sinaimg.cn/dy/deco/2013/0329/logo/LOGO_1x.png",url:"http://www.sina.com"}];$(function () { $('#autocompleteTest').autocomplete({ delay: 500, minLength: 1, source: json,//这里为了测试,直接定义了一个json对象,实际应用中通常是一个url地址 select: function( event, ui ) { $("#autocompleteTest").val(ui.item.label); //location=(ui.item.url); return false; } }).data("ui-autocomplete")._renderItem = function( ul, item ) { var t = item.label; return $("<li></li>") .data("item.autocomplete", item) .append("<a><img src='" + item.pictureurl + "'>" + t + "</a>" ).appendTo(ul); };});</script></body></html> asp的javascript代码 var a =chkArr.split(","); 不能识别 javascript获取客户端mac地址 问个简单的问题 window.resizeTo(screen.width,screen.height); 怎末不全屏啊? 简单问题,但是不会了onunload的事情 鼠标移到某个行上后行变颜色的脚本问题 郁闷的问题,请各位高手帮忙! 查找textbox的问题 窗口属性的控制。 跑来问一下大神们的小问题 表格数据导出JSON js的百分数的正则验证
需要 增加input 的onchange事件 ,就是比如你输入一个"北" , 输入框内容发生变化 ,触发onchange事件 在该事件处理程序中通过ajax获取数据库与"北"相关的城市地址列表,生成下拉列表让你选择 需要使用如Jquery AutoComplete控件,实现较为简单
实现简单么,可是我完全不会js,能不能帮忙写个demo呢,不甚感激 ,还有我自己没有数据库,数据也和天气网一样从别处获取。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>autocomplete测试</title><link rel="stylesheet" type="text/css" href="jquery-ui-1.10.4.custom/css/ui-lightness/jquery-ui-1.10.4.custom.min.css" />
<style>img{width:30px;height:30px;}</style>
<script src="jquery-ui-1.10.4.custom/js/jquery-1.10.2.js"></script>
<script src="jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script>
</head><body>
<input type="text" id="autocompleteTest" autocomplete="off" name="q" value="autocomplete测试" onfocus="if(this.value=='autocomplete测试'){this.value='';}" onblur="if(this.value=='') {this.value = 'autocomplete测试';}" class="ui-autocomplete-input">
<script type="text/javascript">
var json=[{label:"aaa",pictureurl:"http://www.baidu.com/img/bdlogo.gif",url:"http://www.baidu.com"},{label:"bbbbb",pictureurl:"http://i1.sinaimg.cn/dy/deco/2013/0329/logo/LOGO_1x.png",url:"http://www.sina.com"}];
$(function () {
$('#autocompleteTest').autocomplete({
delay: 500,
minLength: 1,
source: json,//这里为了测试,直接定义了一个json对象,实际应用中通常是一个url地址
select: function( event, ui ) {
$("#autocompleteTest").val(ui.item.label);
//location=(ui.item.url);
return false;
}
}).data("ui-autocomplete")._renderItem = function( ul, item ) {
var t = item.label;
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a><img src='" + item.pictureurl + "'>" + t + "</a>"
).appendTo(ul);
};
});</script>
</body>
</html>