强制用户从自动填充列表中选择项目 [英] Force user to select item from autocomplete list

查看:53
本文介绍了强制用户从自动填充列表中选择项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想强制用户从自动完成列表中选择项目。我从链接获得了以下代码。在实现以下javascript函数后,自动生成列表不会出现。如果我删除调用以下javascipt函数,则会出现自动生成列表。

 <   script     type   =  text / javascript    language   =  javascript >  
var isItemSelected = false;
// AutoCompleter的处理程序OnClientItemSelected事件
函数onItemSelected(){
isItemSelected = true;
}
//文本框模糊事件的处理程序
function checkItemSelected(txtPCodebox){
if(!isItemSelected){
alert(请从列表中选择项目) !);
txtPCodebox.focus();
}
else {
// reset isItemSelected
isItemSelected = false;
}
}
< / script >



我无法解决的问题是什么。如果有任何其他方法可以解决同样的问题?请帮助....

解决方案

强迫只会破坏自动完成的目的。这意味着您需要使用一个简单的下拉控件来选择其中一个选项,您仍然可以动态生成这些选项。



-SA

I want to Force user to select item from autocomplete list.I got the following code from a link.after implementing the below javascript functions the autocomplte list does not appear.If i remove calling the below javascipt functions,the autocomplte list appears.

<script type="text/javascript" language="javascript">
       var isItemSelected = false;
       //Handler for AutoCompleter OnClientItemSelected event
       function onItemSelected() {
           isItemSelected = true;
       }
       //Handler for textbox blur event
       function checkItemSelected(txtPCodebox) {
           if (!isItemSelected) {
               alert("Please select item from the list only!");
               txtPCodebox.focus();
           }
           else {
               //reset isItemSelected
               isItemSelected = false;
           }
       }
   </script>


What is the problem i am not able to figure out.If there is any other method to to the same thing?Please help....

解决方案

That "forcing" would simply defeat the purpose of autocomplete. It means that you need to use a simple drop-down control to select one of the options, which you still can generate dynamically.

—SA


这篇关于强制用户从自动填充列表中选择项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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