js下拉列表二级联动
Posted zxrxzw
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js下拉列表二级联动相关的知识,希望对你有一定的参考价值。
<!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下拉列表二级联动的主要内容,如果未能解决你的问题,请参考以下文章