例子:
数据是在别的地方找到的 ^_^
<script type="text/javascript" src="jquery.js"></script>
<script type='text/javascript' src='jquery.autocomplete.js'></script>
<link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" />
<script type="text/javascript">
var v_1 = [
{ name: "深发展A", id: "000001"},
{ name: "万科A", id: "000002"},
{ name: "ST 国 农", id: "000004"},
{ name: "世纪星源", id: "000005"},
{ name: "深振业A", id: "000006"},
{ name: "ST 达 声", id: "000007"},
{ name: "ST宝利来", id: "000008"},
{ name: "中国宝安", id: "000009"}
];
var v_2 = [
{ name: "S ST华新", id: "000010"},
{ name: "山航B", id: "200152"},
{ name: "*ST帝贤B", id: "200160"},
{ name: "雷伊B", id: "200168"},
{ name: "宝石B", id: "200413"},
{ name: "小天鹅B", id: "200418"},
{ name: "粤高速B", id: "200429"},
{ name: "宁通信B", id: "200468"},
{ name: "晨鸣B", id: "200488"},
{ name: "珠江B", id: "200505"},
{ name: "闽灿坤B", id: "200512"},
{ name: "华电国际", id: "600027"}
];
jQuery().ready(function() {
jQuery("#stockInfo").autocomplete(
v_1,{
minChars: 1, //最少输入多少字符开始查询
highlight: false,
scroll: true,
scrollHeight: 200,
width: 153, //宽度
matchContains: true,
matchSubset:false,
formatItem: function(row, i, max) {
return i + "/" + max + ": " + row.name ;
},
formatMatch: function(row, i, max) {
return row.name;
}
});
jQuery("#stockInfo").result(function(event, data, formatted) {
//相关的业务处理
alert(data.id);
});
});
//此方法可以被DWR调用来改变Data
function changeToStockInfo(){
$("#stockInfo")
// clear existing data
.val("")
// change the local data to months
.setOptions({data: v_2})
}
</script>
<div id="content">
<form autocomplete="off">
<p>
<input type="button" value="Change Data" onclick="changeToStockInfo();" />
</p>
<p>
<input type="text" id="stockInfo" />
</p>
</form>
</div>
DWR 如何使用这里不介绍了
主要操作就是在回调方法中直接调用changeToStockInfo()来改变Data数据就可以了
之前以为autocomplete只能有一次初始化,呵呵 没仔细看例子
分享到:
相关推荐
jquery autocomplete下载.rar
在输入页面利用JQuery获取用户输入,然后通过AJAX异步发送到处理页面,...若是jquery autoComplete组件则只要将从后台获取的数据放入autocomplete( url or data, [options] )第一个参数中就行,第二个参数可加可不加。
Jquery AutoComplete
JQuery autocomplete ajax分页,对源码稍微修改了下
jquery.autocomplete.js 、jquery.autocomplete.css
jquery autocomplete 动态补全例子支持中文 ajax传递json数据 文件里有json数据拼接
jquery-autocomplete搜索框自动完成的中文文档,上手快,轻便,功能强大
Jquery autocomplete插件使用
jQuery Autocomplete,百度搜索框提示效果。
jquery-autocomplete 可用
jquery autocomplete.js 是一款优秀的开源JS,支持自动完成,不过如果是中文失效。原因是由于中文编码不一致引起的,修改源文件中AJAX请求中的编码,加上escape编码后,在后台用Server.URLDecode解码后,则中文也...
jquery autocomplete 所需js文件及样式。 实现仿百度输入查询下拉功能。
jQuery plugin: Autocomplete 参数及实例 官网:jQuery plugin: Autocomplete 此插件依赖于 jquery 1.2.6 --- jquery 1.8.3 转自:http://www.cnblogs.com/duanhuajian/p/3398904.html
使用Jquery AutoComplete 插件来做自动填充功能,包含本地数组,后台数据等情况
NULL 博文链接:https://zhaoaiqing.iteye.com/blog/333869
jquery autocomplete官方版(源代码+示例) 自动补充功能非常实用
jquery自动补全插件(jquery autocomplete) 内包含使用说明,前台+后台
jQuery autocomplete 自动加载
jQuery Autocomplete plugin是在jQuery的基础上开发的一套小巧的输入下拉提示插件,这是它的PHP应用实例,大部分功能与HTML格式网页类同,这里增加了一些需要PHp程序配合的内容,它不但有输入提示功能,而且示例本身...