php 加select下拉框三级联动

 <script language="javascript">
     var sbulist=new Array();
     <?php
     require("../include/Conn.php");
     $st="select * from proclasstree where ParentsID!=0";
     $rest=mysql_query($st,$link);
    $num=mysql_num_rows($rest);
     for($i=0;$i<$num;$i++)
     {
       $arr=mysql_fetch_array($rest);
     ?>
     sbulist[<?php echo $i;?>]=new Array("<?php echo $arr["ParentsID"];?>","<?php echo $arr["ID"];?>","<?php echo $arr["ClassName"];?>");
     <?php
     }
     ?>
     function checked1(locationid)
     {
     document.myform.ClassList_2.length=0;
     document.myform.ClassList_2.options[0]=new Option('请选择','');
     for (i=0; i<sbulist.length; i++){
        if (sbulist[i][0] == locationid){
         document.myform.ClassList_2.options[document.myform.ClassList_2.length] = new Option(sbulist[i][2],sbulist[i][1]);
        }
          }
     }
    
     function checked2(locationid)
     {
     document.myform.ClassList_3.length=0;
     document.myform.ClassList_3.options[0]=new Option('请选择','');
     for (i=0; i<sbulist.length; i++){
        if (sbulist[i][0] == locationid){
         document.myform.ClassList_3.options[document.myform.ClassList_3.length] = new Option(sbulist[i][2],sbulist[i][1]);
        }
          }
     }
     </script>
           <select name="ClassList_1" id="ClassList_1" style="width:250px; margin:2px 0;" οnchange="checked1(this.value)">
              <option value="">请选择</option>
     <?php
     //require("../include/Conn.php");
     $rs="select * from proclasstree where ParentsID=0";
     $res=mysql_query($rs,$link);
     $nu=mysql_num_rows($res);
     for($i=0;$i<$nu;$i++)
     {
     $rw=mysql_fetch_array($res);
     echo"<option value='".$rw["ID"]."'>".$rw["ClassName"]."</option>";
     }
     ?>
           </select><br/>
<select name="ClassList_2" id="ClassList_2" style="width:250px; margin:2px 0;"οnchange="checked2(this.value)">
<option value="">请选择</option>
      
</select>
<br/>
<select name="ClassList_3" id="ClassList_3" style="width:250px; margin:2px 0;">
<option value="">请选择</option>

</select>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值