php 加select下拉框三级联动
2010-11-06 08:13
375 查看
<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;" onchange="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;"onchange="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>
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;" onchange="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;"onchange="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>
相关文章推荐
- 省市区三级联动select下拉框,下拉框数据回显 Demo js脚本实现带脚本与案例,整理好了的下载既可用
- php 实现两个select下拉框的数据联动
- 【Vegas原创】PHP+jquery实现select的三级联动
- 如何通过jQuery实现select下拉框的联动效果
- 用php+mysql+json+js+ajax实现省市县三级联动
- jquery+html三级联动下拉框及详情页面加载时的select初始化问题
- PHP+ajax实现省市县三级联动
- example_Jquery Ajax + php 三级联动
- Ajax+php实现商品分类三级联动
- Struts2-<s:doubleselect>标签 联动下拉框
- php+Ajax无刷新三级联动
- php三级联动菜单
- 利用php mysqsl dom 实现省市县三级联动
- 简单易懂的jquery版三级联动select
- PHP+JS三级菜单联动菜单实现方法
- Javascript语言用3个列表框(select)实现的年、月、日三级联动
- 省市区三级联动select
- jquery实现select三级联动(简单易懂)
- php 三级联动菜单
- 关于二级联动/三级联动下拉框的示例代码