liangpz521521
新手上路

UID 91675
精华
0
积分 43
帖子 21
金钱 43 喜悦币
威望 0
人脉 0
阅读权限 10
注册 2007-4-20 来自 河南南阳
状态 离线
|
[广告]: 代充Paypal帐号美元
一个困了我很久的问题
<?php
require("class/database.php");
tep_db_connect() or die('not connect the database.'):
?>
<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).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,ar);
if(v)options[1].selected = true;
}
}
if(++v<s.length){change(v);}
}
}
var dsy = new Dsy();
dsy.add("0",[
<?php
$query=tep_db_query("select * from wed_city where rid='0' and sid='0' order by cid desc");
while($A=tep_db_fetch_array($query))
{
?>
"<?=$A['area']?>",
<?php
}
?>
]);
<?php
$BQUERY=tep_db_query("select * from wed_city where rid='0' and sid='0' order by cid desc");
$i=0;
while($B=tep_db_fetch_array($BQUERY))
{
$CQUERY=tep_db_query("select * from wed_city where rid='".$B['cid']."' and sid='0' order by cid
desc");
?>
dsy.add("0_<?=$i?>",[<?php while($C=tep_db_fetch_array($CQUERY)){?>"<?=$C['area']?>",<?php }?>]);
<?php
$i++;
}
?>
<?php
$EQUERY=tep_db_query("select * from wed_city where rid='0' and sid='0' order by cid desc");
$j=0;
while($E=tep_db_fetch_array($EQUERY))
{
$FQUERY=tep_db_query("select * from wed_city where rid='".$E['cid']."' and sid='0' order by
cid desc");
$k=0;
while($F=tep_db_fetch_array($FQUERY))
{
$GQUERY=tep_db_query("select * from wed_city where rid='".$E['cid']."' and
sid='".$F['cid']."' order by cid desc");
{
?>
dsy.add("0_<?=$j?>_<?=$k?>",[
<?php
while($G=tep_db_fetch_array($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).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);
}
?>
cid area rid sid
2 闸北 1 0
3 彭浦新村 1 2
4 杨浦 1 0
5 长阳路 1 4
6 徐汇 1 0
7 罗秀新村 1 6
8 浙江 0 0
9 杭州 8 0
10 不知道路 8 9
11 海河 8 9
1 上海 0 0
表的关系是这样的,怎么可有取得第三个下拉框的id值,也就是表中cid的值,请高手指教,这个程序是在这里找的
|
|