如何获得用户输入自定义值,并从自动完成单独选择的建议 [英] How to get the user inputted custom value and the selected suggestion from autocomplete seperately

查看:281
本文介绍了如何获得用户输入自定义值,并从自动完成单独选择的建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jQuery自动完成填充建议的文本框和它完美的作品。
麻烦的是,当用户打算输入自己的自定义值。下面给出code给我选择的值:

I'm using jQuery autocomplete to populate suggestion for a textbox and it works perfectly. Trouble is when user intends to enter their own custom value. Below given code gives me the selected value:

 change: function(event, ui) {

    if (ui.item) 
    {
        values=values+ui.item.value;
    }
}

我的问题就用户有意增加了自己的价值,这意味着我必须抓住用户已输入的准确值。按我的要求,我需要添加特殊字符像更复杂? (问号)由具有用来做一个精确搜索自动完成建议的每个选择的值之后。如果用户被限制在只能从自动完成选择它本来是太简单了,我可以追加在这个角色,如果。但是,我怎么能自定义值和建议值区分?
 我怎么能达到呢?但愿是速战速决
任何帮助是AP preciated结果
在此先感谢

My issue far more complicated as user intends to add their own custom value which means I have to to grab the exact value the user has typed in. As per my requirement I need to add a special character like a ? (question mark) after every selected value from the autocomplete suggestion which has to used to do an exact search. If the user was limited to select only from the autocomplete it would have been way too easy and I could append that character inside the if. But how can I differentiate between custom value and suggested value? How can I attain this? Hopefully is a quick fix Any help is appreciated
thanks in advance

推荐答案

只要做一个新的下拉DIV,并有一个脚本:

Simply make a new dropdown div, and have a script:

b.value = a.value

要不断地复制在键入的值。运行在第二个值自动更正,但不是第一个。然后一个事件侦听器添加到该改变了第二个事件

to constantly replicate the value typed in. Run the autocorrect on the second value but not the first. Then add an event listener to the second event that changes

a.value = b.value

一旦点击了。

这篇关于如何获得用户输入自定义值,并从自动完成单独选择的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆