关于创建树形菜单的一些代码[待验证]

      网页类学习笔记 2007-8-9 23:36

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8">
<style type="text/css">
.blur1 { filter:blur(Add=true,Direction=134,Strength=10)}
.style1 {filter: blur(Add=true,Direction=134,Strength=10); font-size: 36px; }
</style>
</head>

<BODY>
<div style="filter:Blur(add=ture,direction=135,strength=100);">pppppppppp</Div>
<p style=filter:blur(add=ture,direction=135,strength=10)><font

size="+3">欢迎来在线!</font></p>
<table>
<tr>
<TD style="FILTER: blur(add=ture,direction=135,strength=10)"><B><FONT
size=+3>欢迎来在线</FONT></B></TD>
</tr>
</table>
<script lanauge=jscript>

var   treebase   =   {  
  rootnum                 :   0  
  };  
   
        function   treeview(nodetxt,nodehref,nodetag){  
            this.childNodes=[];  
    this.txt=nodetxt;  
    if(nodehref==null)  
    this.href="";  
    else  
    this.href=nodehref;  
    this.target=nodetag;  
    if(this.parentNode==null)  
    {  
        this.id="root_"+treebase.rootnum;  
        treebase.rootnum=treebase.rootnum+1;  
    }  
  }  
   
        treeview.prototype.toString=function(){  
              var   str="<div>";  
      var   c_node=this;  
      while(c_node.parentNode)  
      {  
            str=str+"1";  
    c_node=c_node.parentNode;  
      }  
      if   (this.childNodes.length!=0)  
      {  
      if(this.href.length>0)  
  str=str+"<a   href='"+this.href+"'   target='"+this.target+"'  

onclick=\"javascript:showdiv('"+this.id+"_child')\">"+this.txt+"</a>";  
      else            
  str=str+"<a   href=\"javascript:showdiv('"+this.id+"_child')\">"+this.txt+"</a>";  
        }  
        else  
        {  
                if(this.href.length>0)  
  str=str+"<a   href='"+this.href+"'   target='"+this.target+"'>"+this.txt+"</a>";  
      else            
  str=str+this.txt;  
  }  
   
       
      if   (this.childNodes.length!=0)  
      {  
          str=str+"<div   style=\"display:none;\"   id=\""+this.id+"_child\">";  
     
    //var   save_pos=new   Array();  
  //   save_pos.add(this.id);  
      for(var   int_len=0;int_len<this.childNodes.length;int_len++)  
    {  
  //save_pos.push(this.id,int_len);  
  str=str+this.childNodes[int_len];  
  //int_len=save_pos.find(this.id);  
      }    
  str=str+"</div>";  
      }  
       
      str=str+"</div>";  
      return   str;  
        }  
   
        function   showdiv(div_id){  
          var   obj_id=document.getElementById(div_id);  
  obj_id.style.display=(obj_id.style.display=='none'?'block':'none');  
        }  
   
        treeview.prototype.add=function(node){  
            node.parentNode=this;  
            this.childNodes[this.childNodes.length]=node;  
    if   (node.childNodes.length==0)  
    {  
        node.id=this.id+"_child"+this.childNodes.length;          
      }  
    if(node.target==null){  
    node.target=this.target;  
    }  
        }  
  /*  
        Array.prototype.add=function(str_id){  
        this[this.length]=new   Array();  
        this[this.length-1][0]=str_id;              
        }  
   
        Array.prototype.push=function(str_id,int_posi){  
        for(int_arr=0;int_arr<this.length;int_arr++)  
        {  
        if   (this[int_arr][0]=str_id)  
        {  
        this[int_arr][1]=int_posi;  
        }  
        }  
        }  
   
        Array.prototype.find=function(str_id){  
        for(int_arr=0;int_arr<this.length;int_arr++)  
        {  
        if   (this[int_arr][0]=str_id)  
        {  
        return   this[int_arr][1];  
        }  
        }              
        }  
        */
showdiv(a1);
  </script>
<div id=a1>ttt</div>
<div id=a2>ttt</div>
</body>
</html>


  <HTML>  
  <HEAD>  
  <style   type="text/css">  
  <!--  
  .aa   {  
  font-size:   12px;  
  color:   #000000;  
  text-align:   center;  
  vertical-align:   middle;  
  letter-spacing:   0px;  
  word-spacing:   0px;  
  }  
  body,td,th   {  
  font-size:   12px;  
  font-family:   宋体;  
  }  
  body   {  
  background-color:   #CCCCCC;  
  margin-left:   0px;  
  }  
  -->  
  </style>  
  <meta   http-equiv="Content-Type"   content="text/html;   charset=gb2312">  
  </HEAD>  
  <body   >  
  <%    
  dim   cn,rs,SQL   ,Para,NumChild  
  dim   SD,GD'定义深度广度  
  set   cn=server.CreateObject("ADODB.connection")  
  set   rs=server.createobject("ADODB.recordset")  
  set   rs1=server.createobject("ADODB.recordset")  
  cn.Open   "Driver={Microsoft   Access   Driver   (*.mdb)};   DBQ="   &   Server.MapPath("DataBases/wygkno1.mdb")        
  SQL="SELECT   ID,Name,HyperLink,(len(ID)+1)/2   as   SD,RIGHT(ID,   1)   AS   GD   FROM   tree   order   by   ID"    
  rs.open   SQL,cn,1,1        
  do   while   not   rs.EOF    
  SD=rs("SD")  
  '   if   SD>5   then   SD=5   '深度  
    GD=   asc(rs("GD"))-96   '将a,b,c转化为1,2,3  
  ' if   GD>10   then   GD=10   '广度  
  SQL="Select   ID   from   tree   where   ID   like   '"   &   rs("ID")   &   "_%'   and   ID<>'"   &   rs("ID")   &   "'   order   by   ID"  
  Para=rs("ID")   &   "|"  
  NumChild=0  
  rs1.open   SQL,cn,   1,1  
  NumChild=rs1.RecordCount  
  do   while   not   rs1.EOF    
  Para   =Para   &   rs1("ID")   &   "|"  
  rs1.MoveNext    
  loop  
  Para=cstr(trim(left(Para,len(Para)-1)))    
  rs1.Close    
  %>  
  <table   id="T<%=rs("ID")%>"   border=0   cellpadding=0   cellspacing=0   class="aa"   abbr="<%=Para%>"   summary=<%=checkid(rs("ID"))%>   style="cursor:hand"     onClick='vbs:subtree   "<%=Para%>"'   >  
  <tr>    
  <td   width="<%=17+checkid(rs("ID"))*20%>"   height="17"   align="right">    
  <table   width="17"   height="17"   border="1"   cellpadding="0"   cellspacing="3"   bordercolor="#cccccc">  
  <tr>  
  <td   align="center"   valign="middle"   bordercolor="#000000"   id="R<%=rs("ID")%>"   style="font-size:9"   >  
  <%if   NumChild=0   then   Response.Write   "."   else   Response.Write   "+"%>  
  </td>  
  </tr>  
  </table>  
  </td>  
  <td>  
  <img     width="16"   height="16"   src="tree/<%=SD%>/<%=GD%>.gif">  
  </td>    
  <td   height="17"   nowrap   bordercolor="#FFFFFF"   onMouseOver="vbs:me.bgcolor='#CCCCCC':me.bordercolor='#999999'"   onMouseOut="vbs:me.bgcolor='#cccccc':me.bordercolor='#ffffff'"   title="<%=rs("ID")%>"   onclick='vbs:window.location.href="<%=rs("HyperLink")%>"'>    
  <%=rs("Name")%>  
  </td>  
  </tr>  
          </table>  
  <% rs.MoveNext  
  loop  
  rs.Close  
  cn.Close  
  set   rs=nothing  
  set   rs1=nothing  
  set   cn=nothing  
   
  function   checkid(x)        
        checkid=Ubound(split(x,"_"))  
  end   function    
    %>  
  </body   >  
  <script   language=VBS>  
  sub   subtree(Client_para)    
  if   instr(Client_para,"|")=0   then   exit   sub  
  Myarray=split(Client_para,"|")  
  Mytext=trim(eval("R"   &   Myarray(0)   &   ".innertext")   )  
  select   case   Mytext  
  case   "+"  
  document.all.item("R"   &   Myarray(0)).innertext="-"  
  for   i=1   to   ubound(Myarray)  
  if   eval("T"   &   Myarray(i)   &   ".summary")-eval("T"   &   Myarray(0)   &   ".summary")=1   then      
  document.all.item("T"   &   Myarray(i)).style.display="block"  
  end   if  
  if   eval("T"   &   Myarray(i)   &   ".summary")-eval("T"   &   Myarray(0)   &   ".summary")>1   then      
  document.all.item("T"   &   Myarray(i)).style.display="none"  
  end   if  
  next  
  case   "-"    
  document.all.item("R"   &   Myarray(0)).innertext="+"  
  for   i=1   to   ubound(Myarray)  
  if   eval("T"   &   Myarray(i)   &   ".summary")-eval("T"   &   Myarray(0)   &   ".summary")>=1   then      
  document.all.item("T"   &   Myarray(i)).style.display="none"  
  if   eval("R"   &   Myarray(i)   &   ".innertext")="-"   then      
  document.all.item("R"   &   Myarray(i)).innertext="+"  
  end   if    
  end   if  
  next    
  end   select  
  set   Myarray=nothing  
  end   sub  
     
  Sub   document_onselectstart  
  document.selection.clear  
  End   Sub  
     
  if   isobject(eval("Ta"))   then  
  subtree   document.all("Ta").abbr '一次也不执行为全展开  
  subtree   document.all("Ta").abbr   '执行1次为只显示根目录  
  subtree   document.all("Ta").abbr '3次为显示根目录下第一层  
  end   if  
  </script>  
  </HTML>   
   

标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}