Using Asp+xml to implement CSDN menu (database), can be divided into rights management.
Source: Internet
Author: User
When I was developing the company OA system. I'm looking for a csdn menu. But there is this code on the Internet. But it's not database based, and it can't be managed by rights. I wrote one. There is only one program file and one database. But the function is completely realized!
Database structure:
Table:menu
Id
parentid,int,4
menuname,char,20
link,char,50
Table:userlevel
Id
userid,int,4
menuid,int,4
-------------------------------------program source file: Menulist.asp------------------------------
<%
'-------------------------------'
' Source Creative Business Planning Co., Ltd.-OA system
' Module name: A menu that can be controlled by a permission
'-------------------------------'
Set conn = Server.CreateObject ("ADODB. Connection ")
Conn. Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" +server.mappath ("Tree.mdb") + "; Persist Security Info=false ")
%>
<HTML>
<HEAD>
<TITLE> Dstree </TITLE>
<style>
body,td{font:12px Verdana}
#treeBox {background-color: #fffffa;}
#treeBox. ec{margin:0 5 0 5;}
#treeBox. Hasitems{font-weight:bold;height:20px;padding:3 6 0 6;margin:2px;cursor:hand;color: #555555; border:1px Solid #fffffa;}
#treeBox. Items{height:20px;padding:3 6 0 6;margin:1px;cursor:hand;color: #555555; border:1px solid #fffffa;}
</style>
<script>
Code by star 20003-4-7
var HC = "color: #990000; border:1px solid #cccccc";
var SC = "Background-color: #efefef; border:1px solid #cccccc; color: #000000;";
var IO = null;
function Inittree () {
var rootn = document.all.menuXML.documentElement;
var sd = 0;
Document.onselectstart = function () {return false;}
Document.all.treeBox.appendChild (Createtree (ROOTN,SD));
}
function Createtree (THISN,SD) {
var nodeObj = document.createelement ("span");
var upobj = document.createelement ("span");
With (Upobj) {
Style.marginleft = sd*10;
ClassName = Thisn.haschildnodes ()? " Hasitems ":" Items ";
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.