zoukankan      html  css  js  c++  java
  • jq实现地址级联效果

    (function ($) {
        $.fn.Address = function (options) {
            var defaults = {
                divid: "Address",
                callback: function (pageindex) {
                }
            };
            var opts = $.extend(defaults, options);
            var AddressHtml = "";
            AddressHtml = ("<span class="province" ><select id="Pro" name="Region_Province"></select></span>" +
                 "" + "<span class="province" ><select id="city" name="Region_City"><option>地级市</option></select></span>" +
                 "" + "<span class="province"><select  id="area" name="Region_Xian"><option >市县级市</option></select></span>" +
                 "" + "<span class="fillin"><input type="text" id="addressdetial" name="Region_Detail"></span>" +
                "" + "<span id="addressdetialSpan"  style="padding-left:10px;padding-top:3px;"></span>");
            $("#" + opts.divid).html(AddressHtml);
            $.ajax({
                type: "get",
                contentType: 'text/json',
                url: "/common/read",
                dataType: "json",
                success: function (data) {
                    var html = "<option value='0'>省份</option>";
                    $.each(data, function (i, dataitem) {
                        html = html + "<option value='" + dataitem.Code + "'>" + dataitem.Name + "</option>";
                    });
                    $("#Pro").html(html);
                }
            });
            $("#Pro").change(function () {
                var code = $("#Pro").find("option:selected").val();
                $.ajax({
                    type: "get",
                    contentType: 'text/json',
                    url: "/common/ReadSecond",
                    dataType: "json",
                    data: { parentId: code, level: 2 },
                    success: function (data) {
                        var html = "<option value='0'>地级市</option>";
                        $.each(data, function (i, dataitem) {
                            html = html + "<option value='" + dataitem.Code + "'>" + dataitem.Name + "</option>";
                        });
                        $("#city").html(html);
                        $("#area").html("<option value='0'>市县级市</option>");
                    }
                });
            });
            $("#city").change(function () {
                var code = $("#city").find("option:selected").val();
                $.ajax({
                    type: "get",
                    contentType: 'text/json',
                    url: "/common/ReadSecond",
                    dataType: "json",
                    data: { parentId: code, level: 3 },
                    success: function (data) {
                        var html = "<option value='0'>市县级市</option>";
                        $.each(data, function (i, dataitem) {
                            html = html + "<option value='" + dataitem.Code + "'>" + dataitem.Name + "</option>";
                        });
                        $("#area").html(html);
                    }
                });
            });
            
        };
    
    })(jQuery);
    

      

  • 相关阅读:
    Ubuntu下面MySQL的参数文件my.cnf浅析
    Ubuntu下创建XFS文件系统的LVM
    Linux LVM学习总结——Insufficient Free Extents for a Logical Volume
    SQL Server中通用数据库角色权限处理
    Key Lookup开销过大导致聚集索引扫描
    SQL Server OPTION (OPTIMIZE FOR UNKNOWN) 测试总结
    ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
    一次存储过程参数嗅探定位流程总结
    ORACLE如何检查找出损坏索引(Corrupt Indexes)
    MySQL索引扩展(Index Extensions)学习总结
  • 原文地址:https://www.cnblogs.com/liuchang/p/4514811.html
Copyright © 2011-2022 走看看