苦夏的刺猬作品集微盘:急,急,急,关于do while嵌套循环的问题

来源:百度文库 编辑:高考问答 时间:2024/04/30 11:50:14
我想做1个象资源管理器模式的动态目录树;
1级菜单和2级菜单都从数据库调用。代码如下:

<!--#include file="../common/conn.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Dynamic Styles</title>
<style>
<!--
.td {font-size:12pt;}
.f1{COLOR: white;FONT-FAMILY:Arial,楷体_GB2312;font-size:9pt;}
.a1{COLOR:white;FONT-FAMILY:Arial,楷体_GB2312;font-size:9pt;text-decoration:none}
.a1:hover{COLOR:red;FONT-FAMILY:Arial,楷体_GB2312;font-size:9pt;text-decoration:none}
.a1:Link{COLOR:white;FONT-FAMILY:Arial,楷体_GB2312;font-size:9pt;text-decoration:none}
.a1:active{COLOR:red;FONT-FAMILY:Arial,楷体_GB2312;font-size:9pt;text-decoration:none}
-->
</style>
<base target="main">
<script language="javascript">
function showdiv(div_id)
{
if (document.all.item("div"+div_id).style.display == "block")
{
document.all.item("div"+div_id).style.display = "none";
}
else
{
document.all.item("div"+div_id).style.display = "block";
}
}
</script>
</head>
<body TOPMARGIN="0" bottomMargin="4" leftMargin="4" rightMargin="12" background="image1/left-back.jpg">
<%
dim xtyh_id
if session("xtyh_id") = "" then
sql="SELECT xtcd_mc,xtcd_id FROM xtcd where len(rtrim(xtcd_id))=2 "
set rs1=server.createobject("adodb.recordset")
rs1.open sql,conn,1,1
Do While Not rs1.EOF
%>
<table border="0" cellspacing="1" width="100%" cellpadding="0" bgcolor="#505898">
<tr>
<td width="10">├</td>
<td class="f1" nowrap><a class="a1" language="javascript" onClick="showdiv('div1');"><%=rs1("xtcd_mc")%></a></td>
</tr>

<div id="div1" style="display:none">
<%
sql="SELECT xtcd_mc,xtcd_url FROM xtcd where len(rtrim(xtcd_id))=4 and substring(xtcd_id,1,2)="&rs1("xtcd_id")
set rs2=server.createobject("adodb.recordset")
rs2.open sql,conn,1,1
Do While Not rs2.EOF
%>
<table border="0" cellspacing="1" width="100%" cellpadding="0" bgcolor="#505898">
<tr>
<td nowrap>│├<a class="a1" href="<%=rs2("xtcd_url")%>" target="main"><%=rs2("xtcd_mc")%></a> </td>
</tr>

</table>
<%
rs2.MoveNext
Loop
%>
</div>
</table>
<%
rs1.MoveNext
Loop
End If
%>
</body>
</html>

执行后1级目录总是出错:缺少对象。
是怎么回事啊?
我的代码有什么问题吗?

我51前就要交了,还请大哥大姐们帮帮忙啊!!!
如果有 别的方法实现也行啊!!!
如果光把RS2改成静态目录,而RS1不变是仍然出错,是不是我循环的逻辑上有错啊?
补充:这知识部分代码,最后的END IF 可以去掉.

我有一个现成的无限级Asp目录树的类文件,自己写的,能用,但是有一些限制。要的话联系我hhtzxuanyuan@163.com,请给我留电话号码。

你有 if和end if
那么else呢??