码迷,mamicode.com
首页 > Web开发 > 详细

js下拉列表二级联动

时间:2019-06-23 20:46:09      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:class   har   四川   charset   javascrip   pre   col   hang   dmi   

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
    </head>
    <script type="text/javascript">
        cities = new Object();
        cities[‘admin‘]
        cities[‘员工‘] = new Array(‘北京仓‘, ‘山东仓‘, ‘浙江仓‘, ‘安徽仓‘, ‘云南仓‘, ‘江西仓‘, ‘广东仓‘, ‘广西仓‘, ‘海南仓‘,
            ‘湖北仓‘, ‘天津仓‘, ‘河北仓‘, ‘山西仓‘, ‘内蒙古仓‘, ‘吉林仓‘, ‘青海仓‘, ‘陕西仓‘, ‘甘肃仓‘, ‘重庆仓‘, ‘四川仓‘, ‘黑龙江仓‘);
        cities[‘北京仓‘] = new Array(‘admin‘);
        cities[‘山东仓‘] = new Array(‘admin‘);
        cities[‘浙江仓‘] = new Array(‘admin‘);
        cities[‘安徽仓‘] = new Array(‘admin‘);
        cities[‘云南仓‘] = new Array(‘admin‘);
        cities[‘江西仓‘] = new Array(‘admin‘);
        cities[‘广东仓‘] = new Array(‘admin‘);
        cities[‘广西仓‘] = new Array(‘admin‘);
        cities[‘海南仓‘] = new Array(‘admin‘);
        cities[‘湖北仓‘] = new Array(‘admin‘);
        cities[‘河北仓‘] = new Array(‘admin‘);
        cities[‘山西仓‘] = new Array(‘admin‘);
        cities[‘内蒙古仓‘] = new Array(‘admin‘);
        cities[‘吉林仓‘] = new Array(‘admin‘);
        cities[‘青海仓‘] = new Array(‘admin‘);
        cities[‘陕西仓‘] = new Array(‘admin‘);
        cities[‘甘肃仓‘] = new Array(‘admin‘);
        cities[‘重庆仓‘] = new Array(‘admin‘);
        cities[‘四川仓‘] = new Array(‘admin‘);
        cities[‘黑龙江仓‘] = new Array(‘admin‘);

        function set_pt(type, pt) {
            var pv, cv;
            var i, ii;

            pv = type.value;
            cv = pt.value;

            pt.length = 1;

            if (pv == ‘0‘) return;
            if (typeof(cities[pv]) == ‘undefined‘) return;

            for (i = 0; i < cities[pv].length; i++) {
                ii = i + 1;
                pt.options[ii] = new Option();
                pt.options[ii].text = cities[pv][i];
                pt.options[ii].value = cities[pv][i];
            }
        }
    </script>



    <body>
        <form name="form1" action="" method="get">

            <label>我的职位:</label>
            <select name="type" onChange="set_pt(this, this.form.pt);">
                <option value="0">请选择...</option>
                <option value="admin">admin</option>
                <option value="员工">员工</option>
                <option value="上海仓">上海仓</option>
                <option value="北京仓">北京仓</option>
                <option value="山东仓">山东仓</option>
                <option value="浙江仓">浙江仓</option>
                <option value="安徽仓">安徽仓</option>
                <option value="福建仓">福建仓</option>
                <option value="江西仓">江西仓</option>
                <option value="广东仓">广东仓</option>
                <option value="广西仓">广西仓</option>
                <option value="海南仓">海南仓</option>
                <option value="湖北仓">湖北仓</option>
                <option value="天津仓">天津仓</option>
                <option value="河北仓">河北仓</option>
                <option value="山西仓">山西仓</option>
                <option value="内蒙古仓">内蒙古仓</option>
                <option value="青海仓">青海仓</option>
                <option value="陕西仓">陕西仓</option>
                <option value="甘肃仓">甘肃仓</option>
                <option value="四川仓">四川仓</option>
                <option value="云南仓">云南仓</option>
                <option value="重庆仓">重庆仓</option>
                <option value="吉林仓">吉林仓</option>
                <option value="黑龙江仓">黑龙江仓</option>
            </select>

            <label>所属上级:</label>
            <select name="pt" id="pt">
                <option value="0">请选择...</option>
            </select>

        </form>
    </body>
</html>

 

js下拉列表二级联动

标签:class   har   四川   charset   javascrip   pre   col   hang   dmi   

原文地址:https://www.cnblogs.com/zxrxzw/p/11074027.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!