论坛首页 Web前端技术论坛

Asp,帮忙修改一下代码!

浏览 1928 次
该帖已经被评为隐藏帖
作者 正文
   发表时间:2007-05-08  
---------------------------------------------------------------------------------
下面是调用后台的无限级分类,请问如何才能将这个代码写成可收缩的菜单啊?
---------------------------------------------------------------------------------
<!--#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">&nbsp;点击左边分类右边显示列表</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()%>
   发表时间:2007-05-08  
现在是有子类的栏目可以隐藏,但是点击后无法展开,不知道问题出在哪里,还望各们哥哥\姐姐帮忙看一下吧...
0 请登录后投票
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics