我把表单出帖出来.
<SELECT 
            onchange=changelocation1(document.txl.addone_id.options[document.txl.addone_id.selectedIndex].value) 
            name=addone_id>
                  <option value="<? echo $gninfo2[0][0]?>" selected ><? echo $gninfo2[0][1]?></option>
                  <? for($i=1;$i<$user_rows;$i++) {?>
                  <option value="<? echo $gninfo2[$i][0]?>"><? echo $gninfo2[$i][1]?></option>
                  <? }?>
                </select>                  
                  <SELECT 
            name=addtwo_id>
                      <OPTION value="" 
        selected>请选择市</OPTION>
                </SELECT>

解决方案 »

  1.   

    哥们给你个吧,我写的,公司要用的!
    可以从数据库传给函数参数!
    <script language="JavaScript">showProvince('宁夏');</script>
    <script language="JavaScript">cityOfProvince('银川');</script>function showProvince(currentProvince) {
       var province, html, i, pitch;
       province = new Array('北京', '天津', '上海', '重庆', '黑龙江', '吉林', '辽宁', '内蒙古', '河北', '河南', '山东', '山西', '陕西', '甘肃', '宁夏', '青海', '西藏', '新疆', '江苏', '浙江', '安徽', '广东', '海南', '广西', '云南', '贵州', '四川', '福建', '湖南', '江西', '香港', '澳门', '台湾');
       html     = '<select name="provinceList" id="provinceList" onChange="showCity(this.options[this.selectedIndex].value)">';
       html    += '<option value="">省份列表</option>';
       for(i = 0; i < province.length; i++) {
          if(currentProvince == province[i]) {
             pitch = 'selected';
       } else {
             pitch = '';
          }
          html += '<option value="' + province[i] + '" ' + pitch + '>' + province[i] + '</option>';
       }
       html += '</select>';
       document.write(html);
    }function cityOfProvince(currentCity) {
       var html;
       html  = '<select name="cityList" id="cityList">';
       html += '<option value="">城市列表</option>';
       if(currentCity) {
          html += '<option value="' + currentCity + '" selected>' + currentCity + '</option>';
       } else {
          html += '<option value="">省份没选</option>';
       }
       html += '</select>';
       document.write(html);
    }function showCity(currentProvince) {
       var currentCityList, city, i;
       currentCityList = document.getElementById('cityList');
       switch(currentProvince) {
          case '北京' :
             city = new Array('东城', '西城', '宣武');
             break;
          case '宁夏' :
             city = new Array('银川', '石嘴山', '固原');
             break;
          default :
             break;
       }
       if(currentProvince) {
          for(i = 0; i < city.length; i++) {
             currentCityList.options[i] = new Option(city[i], city[i]);
          }
       } else {
          currentCityList.options.length = 1;
          currentCityList.options[0] = new Option('省份没选', '');
       }
    }
      

  2.   

    Web文件中输入
    <script language="JavaScript">showProvince('');</script>
    <script language="JavaScript">cityOfProvince('');</script>
    如果从数据库中输出
    <script language="JavaScript">showProvince('北京');</script>
    <script language="JavaScript">cityOfProvince('东城');</script>
    所输出的省份和城市就能selected
      

  3.   

    不太懂,能把页面发给我看看吗[email protected]