zoukankan      html  css  js  c++  java
  • 用JavaScript获取联动

    <script>
            //联动查询
            $(function () {
                $("#BranchName").change(function () {
                    var parent = $("#BranchName option:selected").val();
                    if (parent != "" && parent !=0 ) {
                        $.ajax({
                            url: "/Store/GetStore?branchId=" + $("#BranchName option:selected").val(),
                            type: "get",
                            success: function (data) {
                                if (data.Data.length > 0) {
                                    var op = "";
                                    for (var i = 0; i < data.Data.length; i++) {
                                        op += "<option  value=" + data.Data[i].Id + ">" + data.Data[i].DealerName + "</option>"
                                    }
                                    $("#DealerName").html(op);
                                    
                                }
                                if (data.Data == "") {
                                    var option = "<option></option>"
                                    $("#DealerName").html(option);
                                }
        
                            }
                        });
                    } else {
                        eqlee.showWarring("请选择分公司和经销商");
                        $("#DealerName").html("<option> 请选择</option>");
                    }
    
                });
            });
        </script>

      

    上面是实现联动脚本

            public JsonResult GetStore(Guid branchId)
            {
                var data = new Models.ReturnJson() { Error = false };
    
                var filter = string.Format(" Deleted = 0 and branchId = '{0}'",branchId);
                var dealerModel = _bllDealer.List(where: filter);
                var id = dealerModel.Select(x => x.Id);
                var dealerName = dealerModel.Select(x => x.DealerName);
    
                data = new Models.ReturnJson() { Error = false, Data = dealerModel };
    
                return JsonNet(data, behavior: JsonRequestBehavior.AllowGet);
            }
    

      上面是后台获取联动的方法

    以上是获取联动的方法,因为没有时间细写,只能简便点。

  • 相关阅读:
    Sum Root to Leaf Numbers——LeetCode
    Search a 2D Matrix ——LeetCode
    Surrounded Regions——LeetCode
    Palindrome Partitioning——LeetCode
    Reverse Linked List II——LeetCode
    Word Break II——LeetCode
    POJ1163——The Triangle
    3Sum Closest——LeetCode
    House Robber——LeetCode
    amqp 抓包
  • 原文地址:https://www.cnblogs.com/seeyougirl/p/8145293.html
Copyright © 2011-2022 走看看