zoukankan      html  css  js  c++  java
  • jquery.autocomplete自动提示的应用

    前台html:

    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head runat="server">
        <title></title>
        <script src="jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>
        <script src="jquery/autocomplete/jquery.autocomplete.min.js" type="text/javascript"></script>
        <link href="jquery/autocomplete/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript">
            $().ready(function() {

            $("#t_person").focus().autocomplete("ajax_do.aspx?page=texttishi&dotype=1", {
                max:1000,
                150,
                selectFirst: false
            });
        });
            
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <input type="text" id="t_person" />
        </div>
        </form>
    </body>
    </html>

    后台(ajax_do.aspx.cs):

            using (SqlConnection con = new SqlConnection(GClass.connMyBo))
            {
                string strRet = "";
                string key = Request.Params["q"].ToString();
                string cmdSel = "select party_id from person where party_id like @key";
                SqlCommand cmd = new SqlCommand(cmdSel, con);
                con.Open();
                cmd.Parameters.AddWithValue("key", "%" + key + "%");
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    strRet +=reader[0].ToString()+"\n";
                }
                Response.Write(strRet);
            }

    备注:

    autocomplete默认的关键字是q,后台可以直接用Request.Params["q"]来获取当前输入文本框的值。

  • 相关阅读:
    hdu 1978
    hdu 2700
    hdu 1176
    hdu 2390
    hdu 2707
    hdu 1804
    hdu 2703
    hdu 2572
    hdu 1171
    React有状态组件和无状态组件
  • 原文地址:https://www.cnblogs.com/Byrd/p/1963684.html
Copyright © 2011-2022 走看看