日期:2014-05-16  浏览次数:20333 次

javascript 两级联动、三级联动、多级联动(三)
<select id="office1"  onchange="ChangeSelect(this.value,'office2','',Office)" style="width:100px"></select>
            <select id="office2" onchange="" style="width:100px"></select>
            <script language="JavaScript" type="text/javascript">ChangeSelect('0','office1','',Office) </script>
            <br />
            <select id="City001"  onchange="ChangeSelect(this.value,'City002','',City2)" style="width:100px"></select>
            <select id="City002" onchange="" style="width:100px"></select>
            <script language="JavaScript" type="text/javascript">ChangeSelect('0','City001','',City2) </script>
            <br />
            <select id="City3001"  onchange="ChangeSelect(this.value,'City3002','',City3)" style="width:100px"></select>
            <select id="City3002"  onchange="ChangeSelect(this.value,'City3003','',City3)" style="width:100px"></select>
             <select id="City3003" onchange="" style="width:100px"></select>
            <script language="JavaScript" type="text/javascript">ChangeSelect('0','City3001','0359',City3) </script>
            <br />
            
      	    <!-- 增加的部分 -->
            <select id="City2001"  onchange="ChangeSelect(this.value,'City2002','',myCity)" style="width:100px"></select>
            <select id="City2002"  onchange="ChangeSelect(this.value,'City2003','',myCity)" style="width:100px"></select>
            <select id="City2003"  onchange="ChangeSelect(this.value,'City2004','',myCity)" style="width:100px"></select>
            <select id="City2004" onchange="" style="width:100px"></select>
            <script language="JavaScript" type="text/javascript">ChangeSelect('0','City2001','029',myCity)</script>
            <br />


使用方式,看最后自己写的那个4级联动。 ["陕西","0","029"], 第一个元素是显示在
select里的选项,第二个元素表示父标签的编号,如果是顶级就选0, 第三个编号是自己的编号。
最后在html select标签中设定数据源为自己编写的myCity, 即可。