• JS制作的简单的三级及联


    前台:

    <form id="form1" runat="server">
            <div><select id="Province">
                <option>请选择</option>
            </select><select id="City">
                 <option>请选择</option>
            </select>
                地区
            <select id="Space">
                 <option>请选择</option>
            </select>
               <script type="text/javascript">
                   $(function () {
                       $.ajax({
                           url: "TestClass/Cascade.ashx?id=1",
                           async: false,
                           success: function (data) {
                               $("#Province").append(data);
                               $("#Province").change(function () {
                                   $.ajax({
                                       url: "TestClass/Cascade.ashx?id=2",
                                       data: { pid: $("#Province").attr("value") },
                                       success: function (data) {
                                           $("#City").html("");
                                           $("#City").append(data);
                                           $("#City").change(
                                               function () {
                                                   $.ajax({
                                                       url: "TestClass/Cascade.ashx?id=3",
                                                       data: { cid: $("#City").attr("value") },
                                                       success: function (data) {
                                                           $("#Space").html("");
                                                           $("#Space").append(data);
                                                       }
                                                   })
                                               })
                                       }
                                   })
                               })
                           }
                       })
                   })
                </script>
            </div>
        </form>

    后台:

      public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/plain";
                if (context.Request.QueryString["id"] == "1")
                {
                    string sql = "SELECT ID,[enname] FROM [ProvinceInfo] WHERE ParentId=0";
                    StringBuilder sb = new StringBuilder();
                    SqlDataReader reader = PubSqlHelperFunc.ExecuteSqlDataReader(CommandType.Text, sql, null);
                    while (reader.Read())
                    {
                        sb.Append("<option value=");
                        sb.Append(reader["Id"]);
                        sb.Append(">");
                        sb.Append(reader["enname"]);
                        sb.Append("</option>");
                    }
                    reader.Close();
                    context.Response.Write(sb.ToString());
                }
                else if (context.Request.QueryString["id"] == "2")
                {
                    string sql = "SELECT ID,[enname] FROM [ProvinceInfo] WHERE ParentId=" + context.Request.Params["pid"] + "";
                    StringBuilder sb = new StringBuilder();
                    sb.Append("<option>请选择</option>");
                    SqlDataReader reader = PubSqlHelperFunc.ExecuteSqlDataReader(CommandType.Text, sql, null);
                    while (reader.Read())
                    {
                        sb.Append("<option value=");
                        sb.Append(reader["Id"]);
                        sb.Append(">");
                        sb.Append(reader["enname"]);
                        sb.Append("</option>");
                    }
                    reader.Close();
                    context.Response.Write(sb.ToString());
                }
                else if (context.Request.QueryString["id"] == "3")
                {
                    string sql = "SELECT ID,[enname] FROM [ProvinceInfo] WHERE ParentId=" + context.Request.Params["cid"] + "";
                    StringBuilder sb = new StringBuilder();
                    sb.Append("<option>请选择</option>");
                    SqlDataReader reader = PubSqlHelperFunc.ExecuteSqlDataReader(CommandType.Text, sql, null);
                    while (reader.Read())
                    {
                        sb.Append("<option value=");
                        sb.Append(reader["Id"]);
                        sb.Append(">");
                        sb.Append(reader["enname"]);
                        sb.Append("</option>");
                    }
                    reader.Close();
                    context.Response.Write(sb.ToString());
                }
            }
  • 相关阅读:
    Spring事务传播特性NOT_SUPPORTED使用演示
    spring配置基于xml的声明式事务
    反射的简单应用
    MyBatis批处理工具类MyBatisBatchHelper.java
    Mybatis分页插件PageHelper的使用
    利用Spring的Profile加载指定数据源
    Nginx状态信息(status)配置及信息详解
    nginx配置基于域名、端口、IP的虚拟主机
    Nginx Linux安装与部署
    rename 批量修改文件名简单用法
  • 原文地址:https://www.cnblogs.com/llcdbk/p/4116247.html
Copyright © 2020-2023  润新知