<?php
include_once("../inc/includer.inc.php");
?>
<html>
<head>
<title>级联菜单</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
body,select
{
font-size:9pt;
font-family:Verdana;
}
a
{
color:red;
text-decoration:none;
}
a:hover{
text-decoration:underline;
}
</style>
<SCRIPT LANGUAGE="JavaScript">
<!--
function Dsy()
{
this.Items = {};
}
Dsy.prototype.add = function(id,iArray)
{
this.Items[id] = iArray;
}
Dsy.prototype.Exists = function(id)
{
if(typeof(this.Items[id]) == "undefined") return false;
return true;
}
function change(v){
var str="0";
for(i=0;i<v;i++){ str+=("_"+(document.getElementById(s[i]).selectedIndex-1));};
var ss=document.getElementById(s[v]);
with(ss){
length = 0;
options[0]=new Option(opt0[v],opt0[v]);
if(v && document.getElementById(s[v-1]).selectedIndex>0 || !v)
{
if(dsy.Exists(str)){
ar = dsy.Items[str];
for(i=0;i<ar.length;i++)options[length]=new Option(ar[i],ar[i]);
if(v)options[1].selected = true;
}
}
if(++v<s.length){change(v);}
}
}
var dsy = new Dsy();
dsy.add("0",[
<?php
$dbInst -> dbConnect($dbconfig['test']);
$query=$dbInst -> query ("select * from test.wed_city where rid='0' and sid='0' order by cid desc");
while($A=$dbInst->fetchArray($query))
{
?>
"<?=$A['area']?>",
<?php
}
?>
]);
<?php
$BQUERY=$dbInst->query("select * from test.wed_city where rid='0' and sid='0' order by cid desc");
$i=0;
while($B=$dbInst->fetchArray($BQUERY))
{
$CQUERY=$dbInst->query("select * from test.wed_city where rid='".$B['cid']."' and sid='0' order by cid desc");
?>
dsy.add("0_<?=$i?>",[<?php while($C=$dbInst->fetchArray($CQUERY)){?>"<?=$C['area']?>",<?php }?>]);
<?php
$i++;
}
?>
<?php
$EQUERY=$dbInst->query("select * from test.wed_city where rid='0' and sid='0' order by cid desc");
$j=0;
while($E=$dbInst->fetchArray($EQUERY))
{
$FQUERY=$dbInst->query("select * from test.wed_city where rid='".$E['cid']."' and sid='0' order by cid desc");
$k=0;
while($F=$dbInst->fetchArray($FQUERY))
{
$GQUERY=$dbInst->query("select * from test.wed_city where rid='".$E['cid']."' and sid='".$F['cid']."' order by cid desc");
{
?>
dsy.add("0_<?=$j?>_<?=$k?>",[
<?php
while($G=$dbInst->fetchArray($GQUERY))
{
?>
"<?=$G['area']?>",
<?php
}
?>
]);
<?php
$k++;
}
}
$j++;
}
?>
//-->
</SCRIPT>
<SCRIPT LANGUAGE = JavaScript>
<!--
var s=["s1","s2","s3"];
var opt0 = ["请选择","请选择","请选择"];
function setup()
{
for(i=0;i<s.length-1;i++)
document.getElementById(s[i]).onchange=new Function("change("+(i+1)+")");
change(0);
}
//-->
</SCRIPT>
</head>
<body bgcolor="#E0E0E0" onLoad="setup()" style="margin:0">
<form name="frm" method="post" action=jn.php>
<select id="s1" name="area"><option>国家</option></select>
<select id="s2" name="city"><option>省份、州</option></select>
<select id="s3" name="county"><option>地级市、县</option></select>
<input type="submit" name="submit">
<input type="hidden" name="action" value="add">
</form>
</body>
</html>
<?php
if($_POST['action']=="add")
{
print_r($_POST);
}
?>