无限级分类树型菜单
来源:互联网 发布:android源码编译 编辑:程序博客网 时间:2024/05/18 16:15
'//----------List表定义
'Create Table List(ID AUTOINCREMENT,ParentID long,Title Text(50),Url Text(50),Flag bit,ChildNum Long,Target Text(10))
'--------------------------
-->
<style Type=Text/Css>
body,td{font-size:13px;}
a:link { color: #442200; text-decoration: none}
a:visited { color: #444400; text-decoration: none}
a:hover { color: #442200; text-decoration: underline overline; background-color: #FFFF00}
a.link1:link { color: #FF0000; text-decoration:none}
a.link1:visited { color: #FF0000; text-decoration: none}
a.link1:hover { color: #FF0000; text-decoration: none; background-color: #eeeeee}
</Style>
<!-- 有人问同一页面不同链接的不同风格怎么做,就是这里啦 -->
<!-- 添加节点表单 -->
<div align="center" id=load style="display:none;position: absolute;">
<TABLE bgcolor=ffffee width=250 Style="border:1px solid #dd8888;"><FORM METHOD=POST ACTION="" name=form1>
<tr><td align="center">添加节点</td></tr>
<TR><TD align="center">
<INPUT TYPE="hidden" Name="ParentID">
标题:<INPUT TYPE="text" NAME="Title"><BR>
链接:<INPUT TYPE="text" NAME="Url"><BR>
目标:<INPUT TYPE="text" NAME="Target" Style="width:70px">
<Select NAME="" Style="width:75px" OnChange="JavaScript:Target.value=this.options[this.selectedIndex].value;">
<!-- 有人问用下拉列表改变文本框的值怎么做,就是这里了 -->
<option value="">Default</option>
<option value="Right">Right</option>
<option value="_black">_black</option>
<option value="_Top">_Top</option>
<option value="_parent">_parent</option>
<option value="_self">_self</option>
</Select>
</td></tr><tr><td align="center">
<INPUT TYPE="submit" Name="提交" value="提交">
<INPUT TYPE="Button" onclick="JavaScript:load.style.display='none'" value="取消">
</TD>
</TR></FORM>
</TABLE>
</div>
<!-- 添加节点表单结束 -->
<%
'连接数据库
set conn=server.createobject("ADODB.Connection")
conn.open "provider=microsoft.jet.oledb.4.0;data source="&server.mappath("File.mdb")
'//----------操作分支
Action=Request("Action")
Select Case Action
Case "Add":If Request("ParentID")<>"" Then Add
Case "Del": Del
Case "Open":Open
Case Else:
End Select
'//----------显示列表
Public List
Set Rs=Conn.Execute("Select * From [List]")
If Not Rs.Eof Then
List =Rs.GetRows
Max=Conn.Execute("Select Count(ParentID) From List Where ParentID=0")(0)
Set Rs=Nothing
Set Conn=Nothing
CheckList 0,Max,""
Else
Set Rs=Nothing
Set Conn=Nothing
End If
Response.Write "<a href=# onclick='JavaScript:form1.action=""List.asp?action=Add"";form1.ParentID.value=0;load.style.left=(document.body.scrollWidth-300)/2;load.style.top=(document.body.scrollHeight)/2;load.style.display="""";'>添加根</a><BR>"
'//------------显示列表函数
FuncTion CheckList(ParentID,Cs,Str1)
Dim j
j=0
For i=0 To Ubound(List,2)
If List(1,i)=ParentID Then
Response.write(Str1)
If j<Cs-1 Then Str2="├" Else Str2="└"
If List(5,i)>0 Then Str2="<a class=Link1 href='List.asp?action=Open&Id="&List(0,i)&"'>"&Str2&"</a>"
If List(5,i)>0 And List(4,i)=False Then Str2="<b>"&Str2&"</b>"
Response.Write(Str2)
Response.Write "<a Href='"&List(3,i)&"' target='"&List(6,i)&"'>"&List(2,i)&"</a> "&VBcrlf
'添加节点链接
Response.Write "<a title='添加"&List(2,i)&"的子节点' href='#' onclick='JavaScript:add("&List(0,i)&");'>添加</a>"&Vbcrlf
Response.Write "<a Title=""删除此节点"&VBCRLF&"此节点的子节点将向上递进一层!"" href='JavaScript:Del("&List(0,i)&");'>删除</a><BR>"
If List(4,i)=True Then
If j<Cs-1 Then CheckList List(0,i),List(5,i),Str1&"┆" Else CheckList List(0,i),List(5,i),Str1&" "'关键所在,递归调用
End If
j=j+1
End IF
Next
End Function
'//-----------添加函数
Function Add
Parent=CLng(Request("ParentID"))
Title=Replace(Request("Title"),"'","''")
Url=Replace(Request("URL"),"'","''")
Target=Replace(Request("Target"),"'","''")
If Title="" or Url="" Then
Response.Write "至少有一个必须参数没有指定值 <a href=List.asp>返回</a>"
Response.End
Exit Function
End If
Sql="Insert Into List (ParentID,Title,Url,Target) Values ("&Parent&",'"&Title&"','"&Url&"',' "&Target&"')"
Conn.Execute(Sql)
If Parent<>0 Then
Sql="Update List Set ChildNum=ChildNum+1 Where ID="&Parent
Conn.Execute(Sql)
End IF
End Function
'//-----切换节点状态
Function Open
Sql="Update List Set Flag=Not Flag Where ID="&Clng(Request("Id"))
Conn.Execute(Sql)
End Function
'//-----------删除节点
Function Del
On Error Resume Next
Id=Clng(Request("ID"))
ParentID=Conn.Execute("Select ParentID From List Where ID="&ID)(0)
Num=Conn.Execute("Select Count(ID) From List Where parentID="&ID)(0)
Conn.Execute("Update List Set ChildNum=ChildNum-1+"&Num&" Where ID="&ParentID)
Conn.Execute("Update List Set ParentID="&ParentID&" Where ID in (Select ID From List Where ParentID="&ID&")")
Conn.Execute("Delete From List Where ID="&ID)
If Err.Number<>0 Then
Response.Write "您做的操作无效,可能是该项已经删除!! <a href=List.asp>返回</a>"
Response.End
End If
End Function
%>
<SCRIPT LANGUAGE="JavaScript">
<!--
function add(ID)
{
form1.action='List.asp?action=Add';
form1.ParentID.value=ID;
load.style.left=(document.body.scrollWidth-300)/2;
load.style.top=(document.body.scrollHeight-100)/2;
load.style.display="";//有人问控制层的隐显怎么做,就是这里啦
}
function Del(ID)
{
if(confirm('删除此节点将使此节点的子节点向上递进一层/n确定要继续吗?'))
{window.location.href='List.asp?Action=Del&Id='+ID;}//有人问删除确认怎么做,就是这里啦}
//-->
</SCRIPT>
--------------------------------------------------------------------------------
Create Table List(ID AUTOINCREMENT,ParentID long,Title Text(50),Url Text(50),Flag bit,ChildNum Long,Target Text(10))
直接在查询里执行就可以得到List表!!
下面是对表的说明
Id 自动编号
ParentID 长整形
Title 文本
Url 文本
Flag 布尔
ChildNum 长整形
Target 文本,允许空符串
'Create Table List(ID AUTOINCREMENT,ParentID long,Title Text(50),Url Text(50),Flag bit,ChildNum Long,Target Text(10))
'--------------------------
-->
<style Type=Text/Css>
body,td{font-size:13px;}
a:link { color: #442200; text-decoration: none}
a:visited { color: #444400; text-decoration: none}
a:hover { color: #442200; text-decoration: underline overline; background-color: #FFFF00}
a.link1:link { color: #FF0000; text-decoration:none}
a.link1:visited { color: #FF0000; text-decoration: none}
a.link1:hover { color: #FF0000; text-decoration: none; background-color: #eeeeee}
</Style>
<!-- 有人问同一页面不同链接的不同风格怎么做,就是这里啦 -->
<!-- 添加节点表单 -->
<div align="center" id=load style="display:none;position: absolute;">
<TABLE bgcolor=ffffee width=250 Style="border:1px solid #dd8888;"><FORM METHOD=POST ACTION="" name=form1>
<tr><td align="center">添加节点</td></tr>
<TR><TD align="center">
<INPUT TYPE="hidden" Name="ParentID">
标题:<INPUT TYPE="text" NAME="Title"><BR>
链接:<INPUT TYPE="text" NAME="Url"><BR>
目标:<INPUT TYPE="text" NAME="Target" Style="width:70px">
<Select NAME="" Style="width:75px" OnChange="JavaScript:Target.value=this.options[this.selectedIndex].value;">
<!-- 有人问用下拉列表改变文本框的值怎么做,就是这里了 -->
<option value="">Default</option>
<option value="Right">Right</option>
<option value="_black">_black</option>
<option value="_Top">_Top</option>
<option value="_parent">_parent</option>
<option value="_self">_self</option>
</Select>
</td></tr><tr><td align="center">
<INPUT TYPE="submit" Name="提交" value="提交">
<INPUT TYPE="Button" onclick="JavaScript:load.style.display='none'" value="取消">
</TD>
</TR></FORM>
</TABLE>
</div>
<!-- 添加节点表单结束 -->
<%
'连接数据库
set conn=server.createobject("ADODB.Connection")
conn.open "provider=microsoft.jet.oledb.4.0;data source="&server.mappath("File.mdb")
'//----------操作分支
Action=Request("Action")
Select Case Action
Case "Add":If Request("ParentID")<>"" Then Add
Case "Del": Del
Case "Open":Open
Case Else:
End Select
'//----------显示列表
Public List
Set Rs=Conn.Execute("Select * From [List]")
If Not Rs.Eof Then
List =Rs.GetRows
Max=Conn.Execute("Select Count(ParentID) From List Where ParentID=0")(0)
Set Rs=Nothing
Set Conn=Nothing
CheckList 0,Max,""
Else
Set Rs=Nothing
Set Conn=Nothing
End If
Response.Write "<a href=# onclick='JavaScript:form1.action=""List.asp?action=Add"";form1.ParentID.value=0;load.style.left=(document.body.scrollWidth-300)/2;load.style.top=(document.body.scrollHeight)/2;load.style.display="""";'>添加根</a><BR>"
'//------------显示列表函数
FuncTion CheckList(ParentID,Cs,Str1)
Dim j
j=0
For i=0 To Ubound(List,2)
If List(1,i)=ParentID Then
Response.write(Str1)
If j<Cs-1 Then Str2="├" Else Str2="└"
If List(5,i)>0 Then Str2="<a class=Link1 href='List.asp?action=Open&Id="&List(0,i)&"'>"&Str2&"</a>"
If List(5,i)>0 And List(4,i)=False Then Str2="<b>"&Str2&"</b>"
Response.Write(Str2)
Response.Write "<a Href='"&List(3,i)&"' target='"&List(6,i)&"'>"&List(2,i)&"</a> "&VBcrlf
'添加节点链接
Response.Write "<a title='添加"&List(2,i)&"的子节点' href='#' onclick='JavaScript:add("&List(0,i)&");'>添加</a>"&Vbcrlf
Response.Write "<a Title=""删除此节点"&VBCRLF&"此节点的子节点将向上递进一层!"" href='JavaScript:Del("&List(0,i)&");'>删除</a><BR>"
If List(4,i)=True Then
If j<Cs-1 Then CheckList List(0,i),List(5,i),Str1&"┆" Else CheckList List(0,i),List(5,i),Str1&" "'关键所在,递归调用
End If
j=j+1
End IF
Next
End Function
'//-----------添加函数
Function Add
Parent=CLng(Request("ParentID"))
Title=Replace(Request("Title"),"'","''")
Url=Replace(Request("URL"),"'","''")
Target=Replace(Request("Target"),"'","''")
If Title="" or Url="" Then
Response.Write "至少有一个必须参数没有指定值 <a href=List.asp>返回</a>"
Response.End
Exit Function
End If
Sql="Insert Into List (ParentID,Title,Url,Target) Values ("&Parent&",'"&Title&"','"&Url&"',' "&Target&"')"
Conn.Execute(Sql)
If Parent<>0 Then
Sql="Update List Set ChildNum=ChildNum+1 Where ID="&Parent
Conn.Execute(Sql)
End IF
End Function
'//-----切换节点状态
Function Open
Sql="Update List Set Flag=Not Flag Where ID="&Clng(Request("Id"))
Conn.Execute(Sql)
End Function
'//-----------删除节点
Function Del
On Error Resume Next
Id=Clng(Request("ID"))
ParentID=Conn.Execute("Select ParentID From List Where ID="&ID)(0)
Num=Conn.Execute("Select Count(ID) From List Where parentID="&ID)(0)
Conn.Execute("Update List Set ChildNum=ChildNum-1+"&Num&" Where ID="&ParentID)
Conn.Execute("Update List Set ParentID="&ParentID&" Where ID in (Select ID From List Where ParentID="&ID&")")
Conn.Execute("Delete From List Where ID="&ID)
If Err.Number<>0 Then
Response.Write "您做的操作无效,可能是该项已经删除!! <a href=List.asp>返回</a>"
Response.End
End If
End Function
%>
<SCRIPT LANGUAGE="JavaScript">
<!--
function add(ID)
{
form1.action='List.asp?action=Add';
form1.ParentID.value=ID;
load.style.left=(document.body.scrollWidth-300)/2;
load.style.top=(document.body.scrollHeight-100)/2;
load.style.display="";//有人问控制层的隐显怎么做,就是这里啦
}
function Del(ID)
{
if(confirm('删除此节点将使此节点的子节点向上递进一层/n确定要继续吗?'))
{window.location.href='List.asp?Action=Del&Id='+ID;}//有人问删除确认怎么做,就是这里啦}
//-->
</SCRIPT>
--------------------------------------------------------------------------------
Create Table List(ID AUTOINCREMENT,ParentID long,Title Text(50),Url Text(50),Flag bit,ChildNum Long,Target Text(10))
直接在查询里执行就可以得到List表!!
下面是对表的说明
Id 自动编号
ParentID 长整形
Title 文本
Url 文本
Flag 布尔
ChildNum 长整形
Target 文本,允许空符串
- 无限级分类树型菜单
- 无限级分类树型菜单
- 无限分类树型菜单演示(asp)
- ASP无限级分类菜单
- php 无限级分类以及树型显示分类关系
- 一个更简单的无限级分类菜单代码
- asp.net中用DropDownList实现无限级分类菜单
- 无限级分类 datagrid (实现树型结构)
- asp+ajax无限级分类树型结构
- 无限级可刷新Js树型菜单
- 无限级Js树型菜单(可刷新)dTree
- 无限级可刷新Js树型菜单
- php无限分类读取多级菜单
- c# 菜单无限极分类-利用递归
- php无限分类 树状菜单经典代码
- php无限分类与树形菜单
- PHP实现菜单无限极分类
- node.js+Mysql实现无限菜单分类
- Perl中的直接引用
- Mappath C# ASP.net
- 测试一下
- 平时很少注意到的宏,源于今天调试程的程序
- 关于IFRAME 自适应高度的研究
- 无限级分类树型菜单
- 软件开发的迭代过程
- 人生的三重境界(山在那?水在那?)
- 读林锐《软件工程思想》------讲述软件开发和做程序员的道理
- 知己难求
- 精妙SQL语句
- 从写队列和池领悟到MVC
- 阿尔伯特·爱因斯坦 和 伯兰特·罗素 对人生的思考
- 在JSP中实现DES加密解密的例子