PHP 三级联动菜单 10
小弟新手,写了一个最简单的下拉列表联动菜单功能,但是有问题,不会解决,麻烦前辈指教一下。<?phpinclude("Conn.php");?><scriptlanguag...
小弟新手,写了一个最简单的 下拉列表 联动菜单功能,但是有问题,不会解决,麻烦前辈指教一下。
<?php include("Conn.php");?>
<script language="javascript" type="text/javascript">
function changevalue(va) //大类传中类
{
window.open("?BigClass="+va,target="_self");
}
function changevalue2(sa)
{
window.open("?MidClass="+sa,target="_self"); //中类传小类
//问题就貌似就出在这里,地址不怎么写哦
}
<?php
$BigClass=$_GET["BigClass"];
$MidClass=$_GET["MidClass"];
$sql=mysql_query("select * from item group by BigClass order by ID",$conn);
?>
<!--大类,对应的字段:BigClass-->
<select name="BigClass" onChange="changevalue(this.value)">
<option value="">请选择省份</option>
<?php while($info=mysql_fetch_array($sql)) { ?>
<option value="<?php echo $info["BigClass"] ?>"<?php if ($info["BigClass"]==$BigClass ){echo 'selected';}?>>
<?php echo $info["BigClass"]?>
</option>
<?php } ?>
</select>
<!--中类,对应的字段:MidClass -->
<?php $sql2=mysql_query("select MidClass from Item where BigClass='".$BigClass."' ");?>
<select name="MidClass" onChange="changevalue2(this.value)">
<option value="">请选择市</option>
<?php while($info=mysql_fetch_array($sql2)) { ?>
<option value="<?php echo $info["MidClass"] ?>"><?php if($info["MidClass"]==$MidClass ){echo 'selected';}?><?php echo $info["MidClass"] ?></option>
<?php } ?>
</select>
<!--小类,对应的字段:SmallClass-->
<?php $sql3=mysql_query("select SmallClass from Item where MidClass='".$MidClass."' ");?>
<select name="SmallClass">
<option value="">请选择区</option>
<?php while($info=mysql_fetch_array($sql3)) { ?>
<option value="<?php echo $info["SmallClass"] ?>"><?php echo $info["SmallClass"] ?></option>
<?php } ?>
</select> 展开
<?php include("Conn.php");?>
<script language="javascript" type="text/javascript">
function changevalue(va) //大类传中类
{
window.open("?BigClass="+va,target="_self");
}
function changevalue2(sa)
{
window.open("?MidClass="+sa,target="_self"); //中类传小类
//问题就貌似就出在这里,地址不怎么写哦
}
<?php
$BigClass=$_GET["BigClass"];
$MidClass=$_GET["MidClass"];
$sql=mysql_query("select * from item group by BigClass order by ID",$conn);
?>
<!--大类,对应的字段:BigClass-->
<select name="BigClass" onChange="changevalue(this.value)">
<option value="">请选择省份</option>
<?php while($info=mysql_fetch_array($sql)) { ?>
<option value="<?php echo $info["BigClass"] ?>"<?php if ($info["BigClass"]==$BigClass ){echo 'selected';}?>>
<?php echo $info["BigClass"]?>
</option>
<?php } ?>
</select>
<!--中类,对应的字段:MidClass -->
<?php $sql2=mysql_query("select MidClass from Item where BigClass='".$BigClass."' ");?>
<select name="MidClass" onChange="changevalue2(this.value)">
<option value="">请选择市</option>
<?php while($info=mysql_fetch_array($sql2)) { ?>
<option value="<?php echo $info["MidClass"] ?>"><?php if($info["MidClass"]==$MidClass ){echo 'selected';}?><?php echo $info["MidClass"] ?></option>
<?php } ?>
</select>
<!--小类,对应的字段:SmallClass-->
<?php $sql3=mysql_query("select SmallClass from Item where MidClass='".$MidClass."' ");?>
<select name="SmallClass">
<option value="">请选择区</option>
<?php while($info=mysql_fetch_array($sql3)) { ?>
<option value="<?php echo $info["SmallClass"] ?>"><?php echo $info["SmallClass"] ?></option>
<?php } ?>
</select> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询