用JS调用,ASP是在服务器端执行的,你这样调用的方法也是不对的,就算可以也不能在客户端网成菜单的关联,可以先用循环将数据库的信息存贮在数组里,在用JS实现,我这有段代码,是管理无极限树菜单的程序,共你参考一下:
<%
dataurl=Server.MapPath("menutree.mdb")
dim conn,strQuery,rs
set conn = server.CreateObject("adodb.connection")
conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE="&dataurl
strQuery="select * from menufun"
set rs=server.createobject("adodb.recordset")
rs.open strQuery,conn,1,1
allnum=rs.RecordCount
MaxLevel=1 '取得最多的层数
for i=1 to allnum
if rs("PartLevel")>MaxLevel then
MaxLevel=rs("PartLevel")
else
MaxLevel=MaxLevel
end if
rs.movenext
next
rs.close
set rs=nothing
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>菜单树管理</title>
<style type="text/css">
<!--
td {
font-size: 12px;
}
-->
</style>
</head>
<script language="javascript">
<!--
var onecount;
onecount=0;
subcat = new Array();
<%
strQuery="select * from menufun where sup_funcid<>'0' and enable<>0"
set rsfun=server.createobject("adodb.recordset")
rsfun.open strQuery,conn,1,1
numfun=rsfun.RecordCount
for j=1 to numfun
%>
subcat[<%=j%>] = new Array("<%=rsfun("funcname")%>","<%=rsfun("sup_funcid")%>","<%=rsfun("funcid")%>");
<%
rsfun.movenext
next
%>
onecount=<%=numfun+1%>;
function changelocation(locationid,fun_no){
document.all("Nclassid"+fun_no).length=0;
var locationid=locationid;
var i;
for(i=1;i<onecount;i++){
if (subcat[i][1] == locationid){
document.all("Nclassid"+fun_no).options[document.all("Nclassid"+fun_no).length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
var funcount
funcount=<%=MaxLevel%>
function disableds(fun_ji){
for(m=fun_ji;m<=funcount;m++){
if(m<=funcount){
document.all("Nclassid"+m).style.display="none";
}
}
}
function alldisableds(){
for(n=1;n<=funcount;n++){
document.all("Nclassid"+n).style.display="";
}
}
//-->
</script>
<body bgcolor="#6699CC" topmargin="0">
<table border="0" cellspacing="2" cellpadding="2">
<tr>
<td>添加菜单项</td>
</tr>
</table>
<form name="myform" method="post" action="" style="margin:0">
<table border="0" cellspacing="2" cellpadding="2">
<tr>
<td align="right">菜单项名称:</td>
<td><input name="textfield" type="text" size="25"></td>
</tr>
<tr>
<td align="right">菜单级别:</td>
<td>
<%for i=1 to Maxlevel+1%><input type="radio" name="PartLevel" value="<%=i%>" onClick="javascript:disableds(<%=i%>)">[<b><%=i%></b>]级<%next%>
</td>
</tr>
<tr>
<td align="right">上级菜单:</td>
<td>
<select name="Nclassid1" id="Nclassid1" onChange="changelocation(document.myform.Nclassid1.options[document.myform.Nclassid1.selectedIndex].value,'2')">
<%
dim rsfun,numfun,funcidfun
strQuery1="select * from menufun where sup_funcid='0' and enable<>0"
set rsfun1=server.createobject("adodb.recordset")
rsfun1.open strQuery1,conn,1,1
numfun1=rsfun1.RecordCount
for k=1 to numfun1
%>
<option value="<%=rsfun1("funcid")%>"><%=rsfun1("funcname")%></option>
<%
rsfun1.movenext
next
rsfun1.close
set rsfun1=nothing
%>
</select>
<%
for i=2 to Maxlevel
if Maxlevel-i=0 then
response.Write(" <select name='Nclassid"&i&"'>")
else
%>
<select name="Nclassid<%=i%>" onChange="javascript:changelocation(document.all('Nclassid<%=i%>').options[document.all('Nclassid<%=i%>').selectedIndex].value,'<%=i+1%>')">
<%
end if
%>
</select>
<%
next
%>
</td>
</tr>
<tr>
<td align="right">指向目标:</td>
<td><input name="textfield2" type="text" size="30"></td>
</tr>
<tr>
<td></td>
<td>
<input type="button" name="Submit1" value="确定">
<input type="button" name="Submit2" value="放弃">
<input type="button" name="Submit3" value="恢复" onClick="javascript:alldisableds()">
</td>
</tr>
</table>
</form>
</body>
</html>
相关文章:无极限树
http://www.bc-cn.net/bbs/dispbbs.asp?boardID=10&ID=35004&page=1
[此贴子已经被作者于2005-11-25 12:32:39编辑过]