zoukankan      html  css  js  c++  java
  • 省市级联操作

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>省市级联操作</title>
    <script type="text/javascript">
        var provinces = new Array(
            new Array("00","--选择省份--"),
            new Array("01","北京市"),
            new Array("02","湖北省"),
            new Array("03","河南省"),
            new Array("04","河北省"),
            new Array("05","江苏省")
        );
        var citys = new Array(
            new Array("0101","北京市"),
            new Array("0102","通州"),
            new Array("0103","五环"),
            new Array("0201","武汉"),
            new Array("0202","武汉"),
            new Array("0203","武汉"),
            new Array("0301","郑州"),
            new Array("0302","郑州"),
            new Array("0303","郑州"),
            new Array("0401","石家庄"),
            new Array("0402","石家庄"),
            new Array("0403","石家庄"),
            new Array("0501","南京"),
            new Array("0502","苏州"),
            new Array("0503","常州")
        );
        function fillprovince(){
            var province = document.getElementById("province");
            for(var i = 0;i<provinces.length;i++){
                var option = new Option(provinces[i][1],provinces[i][0]);
                province.add(option);
            }
        }
        function changeCity(){
            var province = document.getElementById("province");
            var procode = province.options[province.selectedIndex].value;
            var city = document.getElementById("city");
            city.options.length = 0;
            for(var i = 0;i<citys.length;i++){
                if(citys[i][0].substring(0,2)==procode){
                    city.options.add(new Option(citys[i][1],citys[i][0]));
                }
            }
        }
    </script>
    </head>
    <body>
    <select id="province" onchange="changeCity()">
    <script type="text/javascript">fillprovince();</script>
    </select>
    <select id="city" style=" 100px"></select>
    </body>
    </html>

  • 相关阅读:
    易语言VS杀毒软件:基情复燃,转受为攻!
    android xml解析
    Activity中与ListActivity中使用listview区别
    Android四大基本组件介绍与生命周期
    eclipse_中的注释_快捷键
    ADB server didn't ACK
    JDK安装配置
    Android开发把项目打包成apk
    分享Kali Linux 2016.2第48周镜像文件
    iOS10 UI教程视图调试
  • 原文地址:https://www.cnblogs.com/siashan/p/3922496.html
Copyright © 2011-2022 走看看