js怎么实现在搜索框内,根据你输入的一个字然后对应相似的值显示在搜索框下面?
并且鼠标点击下面的任意值,让这个值显示在上面的搜索框里面?
类似于:
求帮忙
jquery autocomplete 插件 http://jqueryui.com/autocomplete/
http://blog.csdn.net/chinacsharper/article/details/17473157
http://blog.sina.com.cn/s/blog_608475eb0100oo2n.html
http://download.csdn.net/detail/zzx42/4334404
原理:监测文本框的变化,通过ajax从后台取得数据显示,我记得w3school有这个例子
items: [
{
xtype: 'textfield',
flex: 1,
name: 'searchstring',
emptyText: '搜索节点',
enableKeyEvents: true,
listeners: {
keypress: function(me, e){
if(e.getKey() == e.ENTER){
this.up().searchNode(this.getValue());
this.focus();
}
}
}
},
{
xtype: 'button',
iconCls: 'ext-icon-search',
handler: function(){
var searchstring = this.up().down('textfield').getValue();
this.up().searchNode(searchstring);//调用的查询方法,根据自己的条件写一个方法就可以了。
}
}
]