xml实现省份和市的选择应用

1.页面
                  省份
                 <select id="province" size="1" onchange="loadCity()" runat="server" NAME="province">
                  <OPTION value="xml/city0.xml" selected>请选择</OPTION>
                  <OPTION value="xml/city01.xml">安徽</OPTION>
                  <OPTION value="xml/city02.xml">北京</OPTION>
                  <OPTION value="xml/city03.xml">福建</OPTION>
                  <OPTION value="xml/city04.xml">甘肃</OPTION>
                  <OPTION value="xml/city05.xml">广东</OPTION>
                  <OPTION value="xml/city06.xml">广西</OPTION>
                  <OPTION value="xml/city07.xml">贵州</OPTION>
                  <OPTION value="xml/city08.xml">海南</OPTION>
                  <OPTION value="xml/city09.xml">河北</OPTION>
                  <OPTION value="xml/city010.xml">河南</OPTION>
                  <OPTION value="xml/city011.xml">黑龙江</OPTION>
                  <OPTION value="xml/city012.xml">湖北</OPTION>
                  <OPTION value="xml/city013.xml">湖南</OPTION>
                  <OPTION value="xml/city014.xml">吉林</OPTION>
                  <OPTION value="xml/city015.xml">江苏</OPTION>
                  <OPTION value="xml/city016.xml">江西</OPTION>
                  <OPTION value="xml/city017.xml">辽宁</OPTION>
                  <OPTION value="xml/city018.xml">内蒙古</OPTION>
                  <OPTION value="xml/city019.xml">宁夏</OPTION>
                  <OPTION value="xml/city020.xml">青海</OPTION>
                  <OPTION value="xml/city021.xml">山东</OPTION>
                  <OPTION value="xml/city022.xml">山西</OPTION>
                  <OPTION value="xml/city023.xml">陕西</OPTION>
                  <OPTION value="xml/city024.xml">上海</OPTION>
                  <OPTION value="xml/city025.xml">四川</OPTION>
                  <OPTION value="xml/city026.xml">天津</OPTION>
                  <OPTION value="xml/city027.xml">新疆</OPTION>
                  <OPTION value="xml/city028.xml">云南</OPTION>
                  <OPTION value="xml/city029.xml">浙江</OPTION>
                  <OPTION value="xml/city030.xml">重庆</OPTION>
                 </select></td>
                <td class="txt12_18">
                 &nbsp;市&nbsp;
                 <select id="city" size="1" runat="server" NAME="city" onchange="getcity()">
                 </select>
                 <xml id="xmlobj"></xml>
                 <script language="javascript" type="text/javascript">
var provobj = document.all("province");
var cityobj = document.all("city");
var xmlhttp = document.all("xmlobj");
loadCity();
/**
 * 装载城市数据
 */
function loadCity() {
 cityobj.options.length = 0;
 var file = provobj.options[provobj.selectedIndex].value;
 xmlhttp.async = false;
 xmlhttp.load(file);
 var cities = xmlhttp.selectNodes("Cities/City");
 var idx,name;

 for(idx = 0; idx < cities.length; idx ++) {
  name = cities[idx].getAttribute("name");
  cityobj.options.length++;
  cityobj.options[cityobj.options.length - 1].value = name;
  cityobj.options[cityobj.options.length - 1].text = name;
 }
 
 
}

<INPUT id="txtgetcity" type="text" runat="server" style="DISPLAY:none">
             <script language="javascript">
               function getcity()
               {
                   document.all("txtgetcity").value = document.all("city").value;
               }
             </script>

2.cs文件中获取txtgetcity的值保存.

posted @ 2006-06-30 15:39  dodo-yufan  阅读(271)  评论(0编辑  收藏  举报