JS+XML 实现 省份和城市之间的联动

本文介绍如何使用JavaScript操作XML文档实现一个简单的表单联动功能。具体包括使用ASP.NET中的TextBox和DropDownList控件创建表单,并通过JavaScript进行省份和城市的联动选择。

用JS来操作一个XML文档来实现一个简单的表单联动
这里是:xml文件
这里是:JS文件
aspx页面:
 <table cellspacing="0" cellpadding="0" width="100%" border="0">
            <tr>
                <td height="25" width="30%" align="right">
                    UName :
                </td>
                <td height="25" width="*" align="left">
                    <asp:TextBox ID="txtUName" runat="server" Width="200px"></asp:TextBox>
                </td>
            </tr>         
            <tr>
                <td height="25" width="30%" align="right">
                    UCountry :
                </td>
                <td height="25" width="*" align="left">
                    <asp:TextBox ID="txtUCountry" runat="server" Width="200px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td height="25" width="30%" align="right">
                    UProvince :
                </td>
                <td height="25" width="*" align="left">
                    <asp:DropDownList ID="ddlUProvince" runat="server"   onchange="ResetCity(this,'ddlUCity');">                 
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td height="25" width="30%" align="right">
                    UCity :
                </td>
                <td height="25" width="*" align="left">
                    <asp:DropDownList ID="ddlUCity" runat="server">
                    </asp:DropDownList>
                </td>
            </tr>
                     
            <tr>
                <td height="25" colspan="2">
                    <div align="center">
                        <asp:Button ID="btnAdd" runat="server" Text="注册" OnClick="btnAdd_Click"></asp:Button>
                    </div>
                </td>
            </tr>
        </table>
  <script>       

InitProvince('ddlUProvince');

 ResetCity(document.getElementById("ddlUProvince"), "ddlUCity");

</script>

aspx.cs:
string province=Request["ddlUProvince"];
string city=Request["ddlUCity"];

转载于:https://www.cnblogs.com/jackcxd/archive/2009/10/13/1582875.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值