当前位置:编程学习 > C#/ASP.NET >>

无刷新易做图联动

  <script type="text/javascript">
        $(function () {
            $.ajax({
                type: "post",
                contentType: "application/json",
                url: "WebService1.asmx/GetListProvince",
                Data: "{}",
                success: function (result) {
                    var strDrop = '';
                    for (var i = 0; i < result.d.length; i++) {
                        strDrop += "<option value='" + result.d[i].provinceID + "' >" + result.d[i].provinceName + "</option>";
                    }
                    $('#Province').append(strDrop);
                }
            })


            $('#Province').change(function () {
                $('#City option:gt(0)').remove();
                $('#Area option:gt(0)').remove();
                $.ajax({
                    type: "post",
                    contentType: "application/json",
                    url: "WebService1.asmx/GetListCity",
                    data: "{Id:'" + $(this).val() + "'}",
                    success: function (result) {
                        var strCity = '';
                        for (var i = 0; i < result.d.length; i++) {
                            strCity += "<option value='" + result.d[i].cityID + "' >" + result.d[i].cityName + "</option>";
                        }
                        $('#City').append(strCity);
                    }
                })
            })


            $('#City').change(function () {
                $('#Area option:gt(0)').remove();
                $.ajax({
                    type: "post",
                    contentType: "application/json",
                    url: "WebService1.asmx/GetListArea",
                    data: "{Id:'" + $(this).val() + "'}",
                    success: function (result) {
                        var strArea = '';
                        for (var i = 0; i < result.d.length; i++) {
                            strArea += "<option value='" + result.d[i].areaID + "' >" + result.d[i].areaName + "</option>";
                        }
                        $('#Area').append(strArea);
                    }
                })
            })


        })
    </script>

 

 

 

<select id="Province">

       <option>--请选择--</option>
    </select>省
    <select id="City">
       <option>--请选择--</option>
    </select>市
    <select id="Area">
      <option>--请选择--</option>

    </select>县

 


WebService

 


      [WebMethod]
        public List<Model.province> GetListProvince()
        {
&

补充:软件开发 , C# ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,