首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

高手求救!javascript调用有关问题

2011-12-12 
高手求救!!!javascript调用问题问题描述:根据管理员的权限在左边导航栏显示相应的功能模块,单击右键的查看

高手求救!!!javascript调用问题
问题描述:根据管理员的权限在左边导航栏显示相应的功能模块,单击右键的查看源代码,可以看到一级目录和二级目录都可以得到.但是在页面一级目录却不能展开.(二级树状菜单)

代码如下:
<%@page   contentType   = "text/html;charset=gb2312 "   import= "com.cmesn.struts.action.left_list,java.sql.* "%>
<%@   page   import= "com.cmesn.struts.Bean.MySqlAdminDAO "   %>
<%@   page   import= "com.cmesn.struts.form.LoginForm; "%>
<html>
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 ">
<style   type= "text/css ">
<!--
.STYLE1   {font-size:   2}
--> a{TEXT-DECORATION:none}
a:link{color:#800080}
a:visited{color:#800080}
a:hover{color:#800080}
                </style>
</head>
<body>
<script   language= "javascript ">
function   ShowTR(objImg,objTr){
if(objTr.style.display== " "){
objTr.style.display= "none ";
objImg.src= "../img/jia.gif ";
objImg.alt= "展开 ";
}else{
objTr.style.display= " ";
objImg.src= "../img/jian.gif ";
objImg.alt= "折叠 ";
}
}
</script>

<table   width= "100% "   height= "40 "   border= "0 "   cellpadding= "0 "   cellspacing= "0 ">
 
  <%  
        left_list   conn   =   null;
        ResultSet   rs_superType   =   null;
       
        HttpSession   sion   =   request.getSession();
          String   name   =   (String)sion.getAttribute( "admin_name ");
          String   passwd   =   (String)sion.getAttribute( "admin_passwd ");
        System.out.println( "************************** "+name);
        System.out.println( "********************************* "+passwd);
        MySqlAdminDAO   dd   =   new   MySqlAdminDAO();
        String   powers   =   dd.getPowers(name,passwd);
        String[]   s   =   powers.split( ", ");  
        for(int   i=0;i <s.length;i++){
              System.out.println( "---------////////// "+s[i]);
                conn   =   new   left_list();
                String   sqls= "select   *   from   cmesn_sort   where   bigsort_id=0   and   sort_id   =   "+s[i]+ "   group   by   Sort_id,Sort   order   by   Sort   desc   ";
        rs_superType   =   conn.check(sqls);
        System.out.println( "####################### "+sqls);
      //   }  
     
int   ID_superType   =0;//获取ID
String   superType=   " ";//获取分模块
int   m=1;
while(rs_superType.next()){
ID_superType   =rs_superType.getInt(1);//获取ID编号


superType   =rs_superType.getString(2);//获取模块
String   sql   = "select   *   from   cmesn_sort   where   bigsort_id= "+ID_superType;//获取相同ID,并把相同ID放在一个模块里面
ResultSet   rs_subType=conn.check(sql);
String   subType= " ";
int   subID=0;
//获取记录数
rs_subType.last();
int   subType_RC=rs_subType.getRow();
rs_subType.first();
  %>
<tr>
<td> <%if(subType_RC <=0){%>
&nbsp;&nbsp;&nbsp;&nbsp;
        <img   src= "../img/jian_null.gif "   width= "16 "   height= "20 "   border= "0 "> <font   size= "3 "> <%=superType%> </font>
<%}else{%>
&nbsp;&nbsp;
<a   href= "Javascript:ShowTR(img <%=m%> ,OpenRep <%=m%> ) "> <img   src= "../img/jia.gif "   border= "0 "   alt= "展开 "   id= "img <%=m%> "> </a>
<font   size= "2.5 "> <%=superType%> </font>
  <%}%> </td>
  <%if(subType_RC> 0){%>
<tr   id= "OpenRep <%=m%> "   style= "display:none; ">
<td   colspan= "6 "> <%do{
        subType=rs_subType.getString(2);
subID=rs_subType.getInt(1);
%>
<table   width= "100% "   border= "0 "   cellspacing= "-2 "   cellpadding= "-2 ">
<tr>
<td   height= "25 "   align= "center "> <table   width= "90% "   cellspacing= "0 "   border= "0 "     cellspacing= "0 "   cellpadding= "0 ">
<tr   onMouseOver= "this.style.background= '#EEEEEE ' "  
onmouseout= "this.style.background= ' ' ">
<td   width= "15% "> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
<td   width= "10% "   align= "center "> <img   src= "../img/folder.gif "   width= "16 "   height= "16 "   border= "0 "> </td>
<td   width= "75% "> <a   href= "../left.do?Type= <%=subID%> "   target   = "right "> <%=subType%> </a> </td>
</tr>
</table> </td>
</tr>
</table>
<%   m++;
}while(rs_subType.next());%> </td>
<%
    }
%>
</tr>
<%
    }
%>
<%
    }
%>
</table>
</body>
</html>


[解决办法]
function ShowTR(objImg,objTr){
if(objTr.style.display== " "){
objTr.style.display= "none ";
objImg.src= "../img/jia.gif ";
objImg.alt= "展开 ";
}else{
//原先的代码objTr.style.display= " ";
//修改后的代码objTr.style.display= "block ";
objImg.src= "../img/jian.gif ";
objImg.alt= "折叠 ";
}
}

热点排行