kingpub

海内存知己,博客若比邻

 

多级树形菜单设计

对应文件有 : machmap.jsp,dtree,js,op.js,dtree.css .

 

数据库设计 sys04_Machine

 

machmap.jsp 代码如下

<%@ page contentType = "text/html; charset=gb2312" language = "java" %>

<%@ page import = "java.sql.*" %>

<%@ page import = "pub.*" %>

< html >

< head >

< title > #.Admin </ title >

< meta http-equiv = "Content-Type" content = "text/html; charset=gb2312" >

< link href = "../css/putong.css" type = "text/css" rel = "stylesheet" >

< link rel = "StyleSheet" href = "../css/dtree.css" type = "text/css" >

< script type = "text/javascript" src = "../js/dtree.js" ></ script >

< script type = "text/javascript" src = "../js/op.js" ></ script >

</ head >

 

< body bgcolor = "ffffff" text = "#000000" >

< table cellSpacing = "0" cellPadding = "0" width = "100%" bgColor = "#bfcae6" border = "0" background = "../images/subtitle.gif" >

    < tr >

       < td width = "100%" height = "26" >< FONT face = " 宋体 " >

          < DIV align = "left" >< FONT face = " 宋体 " color = "#ffffff" > &nbsp;&nbsp; 当前位置:基础信息 &gt;&gt; 组织机构图          </ FONT >

           </ DIV >

           </ FONT >

       </ td >

    </ tr >

  </ table >

  < br >

< a href = "javascript: d.openAll();" > &nbsp;&nbsp; 展开 </ a > &nbsp;&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;&nbsp; < a href = "javascript: d.closeAll();" > 折叠 </ a >

< script type = "text/javascript" >

<!--

    d = new dTree( 'd' );

    d.config.folderLinks= true ;

    //id, pid, name, url, title, target, icon, iconOpen, open     

    d.add(0,-1, 'PICC 组织机构图 ' , '' , 'easydone' , '_blank' );

<%

    //String Sql = "select * from tree";

    String Sql = "select * from sys04_Machine" ;

    String strID= "" ;

    String strPid= "" ;

    String strName= "" ;

    String strCropID= "" ;

    String strUrl= "" ;

    String strTarget= "" ;

    Conn conn= new Conn ();

    DataTable dt = new DataTable();

    //Connection conn = null;

    try {

       conn.execSql(Sql);

       if (conn.querySql(Sql,dt)){

           if (dt.getRowCount()>0){

              for ( int i=0;i<dt.getRowCount();i++){  

                  //strID = dt.getItemForName(i,"id");

                  strID = dt.getItemForName(i, "MachID" );

                  System.out.println( "strID:" +strID);

                  //strPid = dt.getItemForName(i,"pid");

                  strPid = dt.getItemForName(i, "ParentID" );

                  System.out.println( "strPid:" +strPid);

                  strCropID = dt.getItemForName(i, "Cropid" );

                  System.out.println( "strCropID:" +strCropID);

                  //strName = dt.getItemForName(i,"name");

                  strName = dt.getItemForName(i, "MachName" );

                  System.out.println( "strName:" +strName);

                  strUrl = dt.getItemForName(i, "url" );

                  System.out.println( "strUrl:" +strUrl);

                  strTarget = dt.getItemForName(i, "target" );

                  System.out.println( "strTarget:" +strTarget);

                  if (strCropID.equals( "0" )== false && strPid.equals( "0" )== true ){

%>                 

                  d.add( <%= strID %> , <%= strCropID %> , ' <%= strName %> ' , ' <%= strUrl %> ' , ' <%= strName %> ' , ' <%= strTarget %> ' );  

                    

<%

                  }

                  else {

%>

                 d.add( <%= strID %> , <%= strPid %> , ' <%= strName %> ' , ' <%= strUrl %> ' , ' <%= strName %> ' , ' <%= strTarget %> ' );          

<%

                  }  

              }

           }

       }

    }

    catch (Exception ex){

       out.println(ex.toString());

    }

%>

    document.write(d);

//-->

</ script >

</ body >

</ html >

posted on 2006-08-22 16:21 xiaofeng 阅读(515) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

常用链接

留言簿(2)

随笔分类

随笔档案

文章分类

文章档案

收藏夹

搜索

最新评论

阅读排行榜

评论排行榜