必须用JS 实现二级联动 不能使用Jquery

王言祥 发布于 2012/05/18 10:04
阅读 658
收藏 0

前台代码:

 

<%@ Page Title="" Language="C#" MasterPageFile="~/site.master" AutoEventWireup="true" CodeFile="User_Select.aspx.cs" Inherits="User_Select" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
   <script type="text/javascript">


       function Start() {

           var endid = $('#<%=EndTime.ClientID %>').val();
           alert(endid);
           if (endid == "") {
               WdatePicker({ maxDate: "2020-10-01" })
           }
           else {

               WdatePicker({ maxDate: endid })

           }

       }
       function End() {

           var startid = $('#<%=StartTime.ClientID %>').val();
           if (startid == "") {
               WdatePicker({ maxDate: "2020-10-01" });
           }
           else {
               WdatePicker({ minDate: startid });
           }

       }
</script>
<script type="text/javascript">

    function mySplit(str) {
        return  str.split('@');
    }

    function insert(myArray) {

        var lth = myArray.length;
        var list = $('#<%=City.ClientID %>');
        clear();

  注释:  调用 clear()清除城市
        for (var i = 0; i < lth - 1; i++) {
          var option = document.createElement("option");
            option.text = myArray[i];
            option.value = i;
            list.append(option);
        }

    }
    function clear() {

        实现 清除城市的操作

        }
      

     
   
    function s() {
//        var abc = $('#<%=Province.ClientID %>');
//                            alert(abc.length());
    var selectProvince = $('#<%=Province.ClientID %>').val();
       if (selectProvince == "") {
           $('#<%=Province.ClientID %>').val = "请选择";
           $('#<%=City.ClientID %>').val = "请选择";
       }
       else {
           //    selectProvince = "GetProvince.ashx?meth=" + selectProvince;
                          
           $.ajax({
               type: "get",
               url: "GetProvince.ashx",
               data: { "action": selectProvince },
               //    contentType: "application/json;charset=utf-8",
               dataType: "text",
               success: function (result) {
                   var myArray = mySplit(result);
                   insert(myArray);
               }

 

           })
       }
         
      }
   
</script>
   
  
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <form runat="server">
 
<asp:TextBox ID="StartTime" runat="server" onclick="Start()" ></asp:TextBox>
<asp:Image ID="Image2" runat="server"  src="js/My97DatePicker/skin/datePicker.gif"  width="16" height="22"  align="absmiddle"/>
<br />
    <asp:TextBox ID="EndTime" runat="server" onclick="End()"></asp:TextBox>
    <asp:Image ID="Image1" runat="server"  src="js/My97DatePicker/skin/datePicker.gif"  width="16" height="22"  align="absmiddle"/>
    <br />
    Province:
    <asp:DropDownList ID="Province" runat="server" maxlength="180" onchange="s()"
         >
    </asp:DropDownList>

    City:
  
    <asp:DropDownList ID="City" runat="server" maxlength="150"
        >
   
    </asp:DropDownList>
   
</form>
 
 
</asp:Content>

 

省份后台已经绑定  一般处理程序传的是字符串到前台。

 

谢谢给我解答 急用

 

加载中
0
被风遗忘
被风遗忘
你先把代码格式化一下,才有人来回答你的问题.
返回顶部
顶部