测试页面:member/templets/archives_sg_add.htm
效果:

PS:没有什么技术含量,通过自学解决问题而已。

member/archives_sg_add.php添加调用:
require_once(dirname(__FILE__).”/GetArcTypeList.php”);

member/templets/archives_sg_add.htm 在<label>隶属栏目:</label>添加代码:

<label>隶属栏目:</label>
<?php
$typeOpti*****1 = GetOptionListM1(0,$channelid);
echo “<select id=’one’ size=’1′>\r\n”;
echo “<option value=” selected>请选择栏目…</option>\r\n”;
echo $typeOpti*****1;
echo “</select>”;
?> //一级栏目
<span id=”Second”></span> //二级栏目列表
<span id=”Third”></span> //三级栏目列表

<span style=”color:#F00″>*</span>

JS代码:

<script language=’javascript’>
function ShowArcType(UpperFloor,TheFloor,Id)
{
var xmlHttp
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert (“Browser does not support HTTP Request”)
return
}
var url=”GetArcTypeList.php”;
url=url+”?TheFloor=”+TheFloor+”&UpperFloor=”+UpperFloor;
if (Id==2)
{
url=url+”&OpObj=Second&sid=”+Math.random();
}
if (Id==3)
{
url=url+”&OpObj=Third&sid=”+Math.random();
}
xmlHttp.onreadystatechange=function(){ stateChanged(xmlHttp,Id); };
xmlHttp.open(“GET”,url,true);
xmlHttp.send(null)
}

function stateChanged(obj,Id)
{
if (obj.readyState==4 || obj.readyState==”complete”)
{
if (Id==2)
{
document.getElementById(“Third”).innerHTML=””
document.getElementById(“Second”).innerHTML=obj.resp*****eText
}
if (Id==3)
{
document.getElementById(“Third”).innerHTML=obj.resp*****eText
}
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject(“Msxml2.XMLHTTP”);
}
catch (e)
{
xmlHttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}
}
return xmlHttp;
}
</script>

GetArcTypeList.php代码:

<?php
require_once(dirname(__FILE__).”/config.php”);
require_once(DEDEINC.”/dedetag.class.php”);
require_once(DEDEINC.”/userlogin.class.php”);
require_once(DEDEINC.”/customfields.func.php”);
require_once(dirname(__FILE__).”/inc/inc_catalog_opti*****.php”);
require_once(dirname(__FILE__).”/inc/inc_archives_functi*****.php”);
if (!defined(‘DEDEMEMBER’))
{
exit(“dedecms”);
}
$OpObj=$_GET[“OpObj”];
$TheFloor=$_GET[“TheFloor”];
$UpperFloor=$_GET[“UpperFloor”];

if ($OpObj==”Second”)
{
global $OptionArrayListM2,$dsql;
$OptionArrayListM2 = “”;
if ($TheFloor!=”” and $UpperFloor!=””)
{
$dsql->SetQuery(“SELECT
* FROM `#@__arctype` where topid=”.$UpperFloor.” and reid=”.$TheFloor.”
order by sortrank asc”);
$dsql->Execute();
$row = “”;
if ($dsql->GetTotalRow()>0)
{
$OptionArrayListM2 .= “<select id=’two’ size=’1′ onchange=’ShowArcType(“.$TheFloor.”,this.value,3)’>\r\n”;
$OptionArrayListM2 .= “<option value=” selected>请选择…</option>\r\n”;
while($row = $dsql->GetObject())
{
$OptionArrayListM2
.= “<option value='”.$row->id.”‘
class=’option3’>”.$row->typename.”</option>\r\n”;
}
$OptionArrayListM2 .= “</select>”;
}
else
$OptionArrayListM2 = “”;
}
else
$OptionArrayListM2 = “”;
echo $OptionArrayListM2;
}
else if ($OpObj==”Third”)
{
global $OptionArrayListM3,$dsql;
$OptionArrayListM3 = “”;
if ($TheFloor!=”” and $UpperFloor!=””)
{
$dsql->SetQuery(“SELECT
* FROM `#@__arctype` where topid=”.$UpperFloor.” and reid=”.$TheFloor.”
order by sortrank asc”);
$dsql->Execute();
$row = “”;
if ($dsql->GetTotalRow()>0)
{
$OptionArrayListM3 .= “<select id=’three’ size=’1′>\r\n”;
$OptionArrayListM3 .= “<option value=” selected>请选择…</option>\r\n”;
while($row = $dsql->GetObject())
{
$OptionArrayListM3
.= “<option value='”.$row->id.”‘
class=’option3’>”.$row->typename.”</option>\r\n”;
}
$OptionArrayListM3 .= “</select>”;
}
else
$OptionArrayListM3 = “”;
}
else
$OptionArrayListM3 = “”;
echo $OptionArrayListM3;
}

function GetOptionListM1($topid=0,$channeltype=0)//查询指定频道的一级栏目,根据GetOptionListM()仿写的。
{
global $OptionArrayListM1,$dsql;
$dsql->SetQuery(“SELECT * FROM `#@__arctype` where topid=”.$topid.” and channeltype=”.$channeltype.””);
$dsql->Execute();
$OptionArrayListM1 = “”;
$row=””;
//$OptionArrayListM2 .= “<select size=’1′ onchange=’ShowArcType(this.value,this.value,’Second’)’>\r\n”;
while($row = $dsql->GetObject())
{
$OptionArrayListM1
.= “<option value='”.$row->id.”‘
class=’option3′{$selected}>”.$row->typename.”</option>\r\n”;
}
//$OptionArrayListM2 .= “</select>”;
return $OptionArrayListM1;
}
?>

发表评论

电子邮件地址不会被公开。 必填项已用*标注