asp高手进来看看,有谁会做这个?

zyl123456 2007-05-08 04:59:33
---------------------------------------------------------------------------------
下面是调用后台的无限级分类,请问如何才能将这个代码写成可收缩的菜单啊?
---------------------------------------------------------------------------------
<!--#include file="inc/config.asp"-->
<!--#include file="inc/conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="veteadmin/inc/css.css" rel="stylesheet">
<title>目录树</title>
<script language="JavaScript">
function showhide(subid)
{
if (subid.style.display=='none')
{
subid.style.display='block';
}
else
{
subid.style.display='none';
}
}
</script>
</head>
<%
Dim ClassSql,RsClassObj,clid,direct_f
clid=Cint(request("clid"))
direct_f=request("file")
ClassSql = "Select * from downclass where parentID="&clid
Set RsClassObj = Conn.Execute(ClassSql)

Function GetChildClassList(ClassID,Str)
Dim Sql,RsTempObj,TempImageStr,ImageStr
TempImageStr = "<img src=""veteadmin/Images/folder-.gif"" width=""18"" height=""18""><img src=""veteadmin/Images/folder.gif"" width=""18"" height=""18"">"
Sql = "Select * from downclass where ParentID=" & ClassID
ImageStr = Str & "<img src=""veteadmin/Images/folderHR.gif"" width=""18"" height=""18"">"
Set RsTempObj = Conn.Execute(Sql)
do while Not RsTempObj.Eof
GetChildClassList = GetChildClassList & "<table border=""0"" cellspacing=""0"" cellpadding=""0""><tr style=""cursor:hand;"" onDblClick=""DblClickClass(this);"" ChildClassShowTF=""true"" ParentID=""" & RsTempObj("ParentID") & """ ClassID=""" & RsTempObj("id") & """ align=""left"" onClick=""ClickClass(this)"" class=""TempletItem""><td>" & ImageStr & TempImageStr & "</td><td>"& RsTempObj("title") & "</td></tr></table>"
GetChildClassList = GetChildClassList & GetChildClassList(RsTempObj("id"),ImageStr)
RsTempObj.MoveNext
loop
RsTempObj.close
Set RsTempObj = Nothing
End Function
%>
<body topmargin="0" leftmargin="0">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="20" bgcolor="#F0F0F0"> 点击左边分类右边显示列表</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td bgcolor="#FFFFFF">
<table border="0" cellspacing="0" cellpadding="0">
<tr onDblClick="DblClickClass(this);" ChildClassShowTF="true" id="SysRootClass" ParentID="0" ClassID="0" align="left" onClick="ClickClass(this)" class="TempletItem">
<td><img src="veteadmin/Images/Folderk.gif" width="18" height="18"></td>
<td class="TempletSelectItem">系统根栏目</td>
</tr>
</table></td>
</tr>
<%
do while Not RsClassObj.Eof
%>
<tr>
<td bgcolor="#FFFFFF"><table border="0" cellspacing="0" cellpadding="0">
<tr style="cursor:hand;" onDblClick="DblClickClass(this);" ChildClassShowTF="true" ParentID="<% = RsClassObj("ParentID") %>" ClassID="<% = RsClassObj("id") %>" align="left" onClick="ClickClass(this)" class="TempletItem">
<td style="cursor:hand;"><img src="veteadmin/Images/folder-.gif" width="18" height="18"><img src="veteadmin/Images/Folder.gif" onclick="showhide(aa)"></td>
<td><% = RsClassObj("title") %></td>
</tr>
</table></td>
</tr>
<%
Response.Write(GetChildClassList(RsClassObj("id"),""))
RsClassObj.MoveNext
loop
%>
</table>
</body>
</html>
<%
RsClassObj.close
Set RsClassObj = Nothing
%>

</body>
</html>
<script language="JavaScript">
var ParentID='0';
var ClassID='0';
function ClickClass(Obj)
{
if ((Obj.ParentID==null)||(Obj.ClassID==null)) return;
for (var i=0;i<document.all.length;i++) if (document.all(i).className=='TempletSelectItem') document.all(i).className='TempletItem';
Obj.children(1).className='TempletSelectItem';
ParentID=Obj.ParentID;
ClassID=Obj.ClassID;
parent.frames['OpreateWindow'].location='<%=direct_f%>.asp?classid='+ClassID;
}

function DblClickClass(Obj)
{
if (Obj.ChildClassShowTF=='true')
{
HideChildClass(ClassID);
Obj.ChildClassShowTF='false';
//if (Obj.id.toLowerCase()=='SysRootClass') Obj.children(0).children(0).src='../Images/Folder.gif';
//else Obj.children(0).children(1).src='../Images/Folder.gif';
}
else
{
ShowChildClass(ClassID);
Obj.ChildClassShowTF='true';
//if (Obj.id.toLowerCase()=='SysRootClass') Obj.children(0).children(0).src='../Images/FolderK.gif';
//else Obj.children(0).children(1).src='../Images/FolderK.gif';
}
}

function HideChildClass(ID)
{
var CurrObj=null;
for (var i=0;i<document.all.length;i++)
{
CurrObj=document.all(i);
if ((CurrObj.ParentID==ID)&&(CurrObj.id!='SysRootClass'))
{
if (CurrObj.parentElement.parentElement.parentElement.parentElement.tagName.toLowerCase()=='tr')
{
CurrObj.parentElement.parentElement.parentElement.parentElement.style.display='none';
HideChildClass(CurrObj.ClassID);
}
}
}
}

function ShowChildClass(ID)
{
var CurrObj=null;
for (var i=0;i<document.all.length;i++)
{
CurrObj=document.all(i);
if ((CurrObj.ParentID==ID)&&(CurrObj.id!='SysRootClass'))
{
if (CurrObj.parentElement.parentElement.parentElement.parentElement.tagName.toLowerCase()=='tr')
{
CurrObj.parentElement.parentElement.parentElement.parentElement.style.display='';
ShowChildClass(CurrObj.ClassID);
}
}
}
}
</script>
<%call connclose()%>
---------------------------------------------------------------
现在的效果是可以隐藏子菜单,但点击父菜单,却无法展开,请高手看看,应该如何修改?
...全文
246 点赞 收藏 14
写回复
14 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
zyl123456 2007-05-10
再顶
回复
zyl123456 2007-05-09
可是我前后台都已经写好了,如果再来改成梅花雪的,太麻烦了,再说我每个菜单都是写进另外一张表了啊,你看看http://www.vetech.cn/xzzx.asp这个就明白了,我只是想把左侧的菜单收缩起来,要求不高的.

对了,梅花雪的树形菜单能否发一份给我,谢谢zyl82214@163.com
回复
ybcola 2007-05-09
目录树嘛,何必做喃!!用梅花雪的不就得了!
回复
zyl123456 2007-05-09
js代码,我是能看懂,我是指在我发的那段程序中应该如何加入,才行,我现在是程序不知道如何加啊?
-----------------------------------------------------------------------------------
<!--#include file="inc/config.asp"-->
<!--#include file="inc/conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="veteadmin/inc/css.css" rel="stylesheet">
<title>目录树</title>
<script language="JavaScript">
function showhide(subid)
{
if (subid.style.display=='none')
{
subid.style.display='block';
}
else
{
subid.style.display='none';
}
}
</script>
</head>
<%
Dim ClassSql,RsClassObj,clid,direct_f
clid=Cint(request("clid"))
direct_f=request("file")
ClassSql = "Select * from downclass where parentID="&clid
Set RsClassObj = Conn.Execute(ClassSql)

Function GetChildClassList(ClassID,Str)
Dim Sql,RsTempObj,TempImageStr,ImageStr
TempImageStr = "<img src=""veteadmin/Images/folder-.gif"" width=""18"" height=""18""><img src=""veteadmin/Images/folder.gif"" width=""18"" height=""18"">"
Sql = "Select * from downclass where ParentID=" & ClassID
ImageStr = Str & "<img src=""veteadmin/Images/folderHR.gif"" width=""18"" height=""18"">"
Set RsTempObj = Conn.Execute(Sql)
do while Not RsTempObj.Eof
GetChildClassList = GetChildClassList & "<table id='aa' style='display:none' border=""0"" cellspacing=""0"" cellpadding=""0"" ><tr style=""cursor:hand;"" onDblClick=""DblClickClass(this);"" ChildClassShowTF=""true"" ParentID=""" & RsTempObj("ParentID") & """ ClassID=""" & RsTempObj("id") & """ align=""left"" onClick=""ClickClass(this)"" class=""TempletItem""><td>" & ImageStr & TempImageStr & "</td><td>"& RsTempObj("title") & "</td></tr></table>"
GetChildClassList = GetChildClassList & GetChildClassList(RsTempObj("id"),ImageStr)
RsTempObj.MoveNext
loop
RsTempObj.close
Set RsTempObj = Nothing
End Function
%>
<body topmargin="0" leftmargin="0">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="20" bgcolor="#F0F0F0"> 点击左边分类右边显示列表</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td bgcolor="#FFFFFF">
<table border="0" cellspacing="0" cellpadding="0">
<tr onDblClick="DblClickClass(this);" ChildClassShowTF="true" id="SysRootClass" ParentID="0" ClassID="0" align="left" onClick="ClickClass(this)" class="TempletItem">
<td><img src="veteadmin/Images/Folderk.gif" width="18" height="18"></td>
<td class="TempletSelectItem">系统根栏目</td>
</tr>
</table></td>
</tr>
<%
do while Not RsClassObj.Eof
%>
<tr>
<td bgcolor="#FFFFFF"><table border="0" cellspacing="0" cellpadding="0">
<tr style="cursor:hand;" onDblClick="DblClickClass(this);" ChildClassShowTF="true" ParentID="<% = RsClassObj("ParentID") %>" ClassID="<% = RsClassObj("id") %>" align="left" onClick="ClickClass(this)" class="TempletItem">
<td style="cursor:hand;"><img src="veteadmin/Images/folder-.gif" width="18" height="18"><img src="veteadmin/Images/Folder.gif" onclick="showhide(aa)"></td>
<td><% = RsClassObj("title") %></td>
</tr>
</table></td>
</tr>
<%
Response.Write(GetChildClassList(RsClassObj("id"),""))
RsClassObj.MoveNext
loop
%>
</table>
</body>
</html>
<%
RsClassObj.close
Set RsClassObj = Nothing
%>

</body>
</html>
<script language="JavaScript">
var ParentID='0';
var ClassID='0';
function ClickClass(Obj)
{
if ((Obj.ParentID==null)||(Obj.ClassID==null)) return;
for (var i=0;i<document.all.length;i++) if (document.all(i).className=='TempletSelectItem') document.all(i).className='TempletItem';
Obj.children(1).className='TempletSelectItem';
ParentID=Obj.ParentID;
ClassID=Obj.ClassID;
parent.frames['OpreateWindow'].location='<%=direct_f%>.asp?classid='+ClassID;
}

function DblClickClass(Obj)
{
if (Obj.ChildClassShowTF=='true')
{
HideChildClass(ClassID);
Obj.ChildClassShowTF='false';
//if (Obj.id.toLowerCase()=='SysRootClass') Obj.children(0).children(0).src='../Images/Folder.gif';
//else Obj.children(0).children(1).src='../Images/Folder.gif';
}
else
{
ShowChildClass(ClassID);
Obj.ChildClassShowTF='true';
//if (Obj.id.toLowerCase()=='SysRootClass') Obj.children(0).children(0).src='../Images/FolderK.gif';
//else Obj.children(0).children(1).src='../Images/FolderK.gif';
}
}

function HideChildClass(ID)
{
var CurrObj=null;
for (var i=0;i<document.all.length;i++)
{
CurrObj=document.all(i);
if ((CurrObj.ParentID==ID)&&(CurrObj.id!='SysRootClass'))
{
if (CurrObj.parentElement.parentElement.parentElement.parentElement.tagName.toLowerCase()=='tr')
{
CurrObj.parentElement.parentElement.parentElement.parentElement.style.display='none';
HideChildClass(CurrObj.ClassID);
}
}
}
}

function ShowChildClass(ID)
{
var CurrObj=null;
for (var i=0;i<document.all.length;i++)
{
CurrObj=document.all(i);
if ((CurrObj.ParentID==ID)&&(CurrObj.id!='SysRootClass'))
{
if (CurrObj.parentElement.parentElement.parentElement.parentElement.tagName.toLowerCase()=='tr')
{
CurrObj.parentElement.parentElement.parentElement.parentElement.style.display='';
ShowChildClass(CurrObj.ClassID);
}
}
}
}
</script>
<%call connclose()%>
----------------------------------------------------------------------------------
我在上面的GetChildClassList = GetChildClassList & "<table id='aa' style='display:none' border=""0"" cellspacing=""0"" cellpadding=""0"" >这里加入了id和style,还在<img src="veteadmin/Images/Folder.gif" onclick="showhide(aa)">这里加入了onclick,但现在是有子类的都隐藏了,点击父类,无法展开子类,请大哥帮忙修改一下,好吗?
回复
Tameway 2007-05-09
落伍全是IDC商,恐怕也没几个会帮你改吧。。。
回复
Atai-Lu 2007-05-09
function Show(id){//调用函数的时候,传递一个参数过来,参数指明需要展开或收缩的菜单编号
var obj=document.getElementById('c_'+id);//获取需要展开或收缩的菜单ID
//我是以"c_1"、"c_2"...这样的命名规则命名的,如果需要修改,你自己改
var img=document.getElementById('img_'+id);//获取需要替换的图片ID
//这个主要用来变换不同的图片,以使被展开菜单与收缩菜单在视觉上有所区别
//我用的两个图片名分别为cate_off.gif、cate_on.gif
if(obj.style.display=="none"){//如果是需要展开,先判断先前状态是否是收缩状态
obj.style.display="";//展开
img_re=new RegExp("_on\.gif$");//用正则替换
img.src=img.src.replace(img_re,'_off.gif');开始替换图片
}else{//如果是关闭菜单
obj.style.display="none";//关闭
img_re=new RegExp("_off\.gif$")//;
img.src=img.src.replace(img_re,'_on.gif');//替换图片
}
}
============================================
菜单那你不管用什么,至少ID得这么命名,如果上面的代码没做任何修改的话
<a style="cursor:pointer;" onClick="Show(1)"><img id="img_1" src="../images/cate_on.gif" border="0" align="absmiddle" />主菜单一</a>
<div id="c_1" style="display:none">//如果默认是展开,请修改style="display:none"的属性为style="display:"
子菜单一
子菜单二
</div>
......以下省略,说得已经够详细,再不懂就没办法了
回复
zyl123456 2007-05-09
楼上的哥哥,应该怎么改啊,偶就是不会改,还望多指教。。。
回复
zyl123456 2007-05-09
有人在吗?大哥大姐们
回复
潮之金龙 2007-05-08
上网找个能伸缩的改一下不就行了
回复
zyl123456 2007-05-08
不会吧,这里没有热心人吗
算了,我去落伍看看
回复
webxy 2007-05-08
给钱就有人会做了..哈..哈....
回复
zyl123456 2007-05-08
哥哥,姐姐们快进来吧,急啊...
回复
zyl123456 2007-05-08
没人懂吗?
回复
zyl123456 2007-05-08
沙发先做...
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2007-05-08 04:59
社区公告
暂无公告