主题:求助/求一VBScipt的ASP无限分级树型菜单代码~
我有JAVAScript的,或者帮忙改一改~
<%
function ShowId(id,parentid,name){//显示
var rssort = Server.CreateObject("ADODB.Recordset");
rssort.ActiveConnection = MM_fsyuxidata_STRING;
rssort.Source = "SELECT * FROM ClassTree where followid="+id;
//判断是否是最后一级(检索数据库查看时候还有子节点)
rssort.CursorType = 3;
rssort.CursorLocation = 3;
rssort.LockType = 3;
rssort.Open();
if(rssort.RecordCount==0){//判断是否是最后一级,如果是最后一级则显示树的最后一级(insdoc),否则继续展开(insFld)
var strOutput1 = "insDoc(ax"+parentid+", gLnk (0,'"+name+"','product.asp?id="+id+"','ftv2doc.gif'));";
Response.Write(strOutput1);
}
else{
var strOutput1 = "ax"+id+"=insFld(ax"+parentid+", gFld ('"+name+"','product.asp?id="+id+"','ftv2folderopen.gif', 'ftv2folderclosed.gif'));";
Response.Write(strOutput1);
}
rssort.close();
}
function ShowTopic(){//初始tree
var rsreply = Server.CreateObject("ADODB.Recordset");
rsreply.ActiveConnection = MM_fsyuxidata_STRING;
rsreply.Source = "SELECT * FROM ClassTree";
rsreply.CursorType = 3;
rsreply.CursorLocation = 3;
rsreply.LockType = 3;
rsreply.Open();
ShowChieldren(rsreply,0,0);
rsreply.Close();
}
function ShowChieldren(rsreply,iParentId,iPreviousFilter){//取子节点,形成递归
var iCurrentLocation;
rsreply.Filter = " followid = '" + iParentId+"'";
if(rsreply.RecordCount!=0){
if(!rsreply.BOF) rsreply.MoveFirst();
while(!rsreply.EOF){
ShowId(rsreply.Fields.Item("id").value,rsreply.Fields.Item("followid").value,rsreply.Fields.Item("classname").value);
iCurrentLocation = rsreply.AbsolutePosition;
ShowChieldren(rsreply,rsreply.Fields.Item("id").Value,rsreply.Filter);
//循环内调用自身取符合Filter的记录
rsreply.AbsolutePosition = iCurrentLocation;
rsreply.MoveNext();
}
}
rsreply.Filter = iPreviousFilter;
}
%>
<%
ShowTopic();
%>
因为要include到另一VBScript的ASP页面~
<%
function ShowId(id,parentid,name){//显示
var rssort = Server.CreateObject("ADODB.Recordset");
rssort.ActiveConnection = MM_fsyuxidata_STRING;
rssort.Source = "SELECT * FROM ClassTree where followid="+id;
//判断是否是最后一级(检索数据库查看时候还有子节点)
rssort.CursorType = 3;
rssort.CursorLocation = 3;
rssort.LockType = 3;
rssort.Open();
if(rssort.RecordCount==0){//判断是否是最后一级,如果是最后一级则显示树的最后一级(insdoc),否则继续展开(insFld)
var strOutput1 = "insDoc(ax"+parentid+", gLnk (0,'"+name+"','product.asp?id="+id+"','ftv2doc.gif'));";
Response.Write(strOutput1);
}
else{
var strOutput1 = "ax"+id+"=insFld(ax"+parentid+", gFld ('"+name+"','product.asp?id="+id+"','ftv2folderopen.gif', 'ftv2folderclosed.gif'));";
Response.Write(strOutput1);
}
rssort.close();
}
function ShowTopic(){//初始tree
var rsreply = Server.CreateObject("ADODB.Recordset");
rsreply.ActiveConnection = MM_fsyuxidata_STRING;
rsreply.Source = "SELECT * FROM ClassTree";
rsreply.CursorType = 3;
rsreply.CursorLocation = 3;
rsreply.LockType = 3;
rsreply.Open();
ShowChieldren(rsreply,0,0);
rsreply.Close();
}
function ShowChieldren(rsreply,iParentId,iPreviousFilter){//取子节点,形成递归
var iCurrentLocation;
rsreply.Filter = " followid = '" + iParentId+"'";
if(rsreply.RecordCount!=0){
if(!rsreply.BOF) rsreply.MoveFirst();
while(!rsreply.EOF){
ShowId(rsreply.Fields.Item("id").value,rsreply.Fields.Item("followid").value,rsreply.Fields.Item("classname").value);
iCurrentLocation = rsreply.AbsolutePosition;
ShowChieldren(rsreply,rsreply.Fields.Item("id").Value,rsreply.Filter);
//循环内调用自身取符合Filter的记录
rsreply.AbsolutePosition = iCurrentLocation;
rsreply.MoveNext();
}
}
rsreply.Filter = iPreviousFilter;
}
%>
<%
ShowTopic();
%>
因为要include到另一VBScript的ASP页面~