• autocomplete.js的使用(1):自动输入时,出现下拉选择框


    autocomplete.js可以实现自动输入文本值,并出现下拉框

    js引用:所需要的autocomplete文件需要在网站中自行下载。

        <!--自动输入文本值所需的jquery文件-->
        <script src="../js/autocomplete/lib/jquery.js" type="text/javascript"></script>
        <script src="../js/autocomplete/lib/jquery.bgiframe.min.js" type="text/javascript"></script>
        <script src="../js/autocomplete/jquery.autocomplete.js" type="text/javascript"></script>
        <link href="../js/autocomplete/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
        <script src="../js/autocomplete/lib/jquery.dimensions.js" type="text/javascript"></script>

    Html语句:

    <div>目的地:<asp:TextBox ID="TextBox_City" style="padding-left:5px;height:25px;550px;line-height:18px;font-size:12px;" runat="server"></asp:TextBox> </div>
    

    js语句:可是实现多个的选择

    <script language="javascript" type="text/javascript">
             $(document).ready(function(){
                $("#TextBox_City").autocomplete("../GoldenPalmInsurance/Code/CountryName.ashx",{
                    minChars: 1,                   //最少输入字条
                    max: 30,
                    autoFill: false,                //是否选多个,用","分开
                    mustMatch: false,               //是否全匹配, 如数据中没有此数据,将无法输入
                    matchContains: true,            //是否全文搜索,否则只是前面作为标准
                     331,
                    multiple: true,
                    scrollHeight: 200//提示高度,溢出时显示滚动条
                });
                });
     </script>
    CountryName.ashx文件中程序如下:
    public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "application/json";
                //取得TextBox的文字
                string q = context.Request.QueryString["q"] == null ? "" : context.Request.QueryString["q"].ToString();
                if (!string.IsNullOrEmpty(q))
                {
                    //LINQ查询
                    using (QuDataDataContext Qucontext=new QuDataDataContext())
                    {
                        var Query = from a in Qucontext.countryinfos
                                    where a.cname.Contains(q) || a.ename.Contains(q)
                                    orderby a.ename
                                    select a.cname+'/'+a.ename;
                        string json = "申根/schengen  state" + Environment.NewLine + string.Join(Environment.NewLine, Query.ToArray());
                        //將查詢結果輸出
                        context.Response.Write(json);
                    }
                }
               
            }
  • 相关阅读:
    Linux环境变量文件
    Hadoop的ERROR: Attempting to operate on yarn resourcemanager as root的解决方法
    如何启用WSS3.0的匿名访问?
    Microsoft Windows SharePoint Services 3.0
    在sps页面中在新窗口打开文档
    wss3.0安装时的bug
    使用GROUP BY子句的规则
    8种Nosql数据库系统对比
    django学习
    Python socket编程
  • 原文地址:https://www.cnblogs.com/ly77461/p/5732961.html
Copyright © 2020-2023  润新知