<!--基于php+mysql的二级动态级联菜单(By:sunlion)+++开始-->
<FORM name="FormData1" METHOD="POST" action="savenews.php">
<select name="c_idc" onChange="getCity2(document.FormData1.c_idc.options[document.FormData1.c_idc.selectedIndex].value);" size="1">
<option selected>请选择</option>
<?
$result4=mysql_query("select * from bigsort group by Id order by Id desc";
while($rs1=mysql_fetch_array($result4)){
?>
<option value="<?=$rs1['Id'];?>"><?=$rs1['bigsortname'];?></option>
<?
}
?>
</select>
<select name="list_id">
<option selected value="">请选择</option>
</select>
<script language = "JavaScript">
var onecount2;
onecount2 = 0;
subcat2 = new Array();
<?
$count2=0;
$result5=mysql_query("select * from smallsort order by bigsortid desc";
while($rs2=mysql_fetch_array($result5)){
?>
subcat2[<?=$count2;?>] = new Array("<?=$rs2['smallsortname'];?>","<?=$rs2['bigsortid'];?>","<?=$rs2['smallsortname'];?><?=$rs2['bigsortid'];?>";
<?
$count2++;
}
?>
onecount2=<?=$count2?>;
function getCity2(provinceId)
{
document.FormData1.list_id.length = 0;
var locationid=provinceId;
var i;
document.FormData1.list_id.options[0] = new Option('请选择','');
for (i=0;i<onecount2;i++)
{
if (subcat2[i][1] == locationid)
{
document.FormData1.list_id.options[document.FormData1.list_id.length] = new Option(subcat2[i][2], subcat2[i][0]);
}
}
}
</script>
</form>
接受页面如下接受数据
$bigsort=$_POST["c_idc"];
$smallsort=$_POST["list_id"];
<!--基于php+mysql的二级动态级联菜单(By:sunlion)+++结束-->