隨筆 - 147  文章 - 71  trackbacks - 0
          <2009年2月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          1234567

          常用鏈接

          留言簿(1)

          隨筆分類(146)

          隨筆檔案(147)

          文章分類(28)

          文章檔案(28)

          喜歡的Blog

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          <%@ page language="java" pageEncoding="utf-8"%>
          <%
              
          String path = request.getContextPath();
              
          String basePath = request.getScheme() + "://"
                      
          + request.getServerName() + ":" + request.getServerPort()
                      
          + path + "/";
          %>

          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
          <html>
              
          <head>
                  
          <base href="<%=basePath%>">

                  
          <title>表格折疊效果</title>

                  
          <meta http-equiv="pragma" content="no-cache">
                  
          <meta http-equiv="cache-control" content="no-cache">
                  
          <meta http-equiv="expires" content="0">
                  
          <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
                  
          <meta http-equiv="description" content="This is my page">

              
          </head>

          <script language="javascript">   
          function initTable(){      
              
          var tableRows=tb.rows;    
              
          for(i=0;i<tableRows.length;i++){
                  
          if(tableRows[i].id.indexOf("-")>0)
                        tableRows[i].style.display
          ="none";
              }
          }
          function showRow(tid){   
              
          var tableRows=tb.rows;
              
          for(j=0;j<tableRows.length;j++){
                  
          var s=tableRows[j].id;
                  
          var tmp=tid.id+"-";
                  
          if(s.indexOf(tmp)!=-1 && s!=tid.id){
                         
          //alert(s);
                      if(tableRows[j].style.display==""){   
                          tableRows[j].style.display
          ="none"
                          tid.cells[
          0].firstChild.data="+";
                      }  
                      
          else
                          tableRows[j].style.display
          =""
                          tid.cells[
          0].firstChild.data="-";
                      }
                  }
              }    
          }   
          </script>

              
          <body onLoad="initTable()">
                  
          <table width="10%" cellpadding="0" cellspacing="0" id="tb"
                      style
          ="border-collapse: collapse" border="0" bordercolor="#111111">
                      
          <tr id="t0" onClick="showRow(this)">
                          
          <th align="left" style="cursor: hand;" width="20%">
                              +
                          
          </th>
                          
          <th align="left" scope="col" width="80%">
                              標題1
                          
          </th>
                      
          </tr>
                      
          <tr id="t0-1">
                          
          <td>
                          
          </td>
                          
          <td>
                              1
                          
          </td>
                      
          </tr>
                      
          <tr id="t0-2">
                          
          <td>
                          
          </td>
                          
          <td>
                              2
                          
          </td>
                      
          </tr>
                      
          <tr id="t3" onClick="showRow(this);">
                          
          <th align="left" style="cursor: hand;">
                              +
                          
          </th>
                          
          <th align="left" scope="col">
                              標題2
                          
          </th>
                      
          </tr>
                      
          <tr id="t3-1">
                          
          <td>
                          
          </td>
                          
          <td>
                              3
                          
          </td>
                      
          </tr>
                  
          </table>
          </html>
          posted on 2009-02-20 09:54 飛翔天使 閱讀(2790) 評論(1)  編輯  收藏 所屬分類: javascript

          FeedBack:
          # re: 表格的折疊展開 2009-02-20 13:33 jeasonzhao
          在展開、隱藏的時候可能會導致布局錯位啊  回復  更多評論
            
          主站蜘蛛池模板: 富民县| 莱西市| 定兴县| 紫阳县| 荆门市| 股票| 汉寿县| 临泽县| 辽阳县| 察隅县| 吴忠市| 龙游县| 龙海市| 绍兴市| 安福县| 仪征市| 简阳市| 桓台县| 宁晋县| 和静县| 耒阳市| 永春县| 通道| 壤塘县| 江源县| 石阡县| 利津县| 普定县| 万全县| 广宁县| 高邑县| 临潭县| 和顺县| 太白县| 临漳县| 临安市| 无为县| 嵊州市| 万安县| 上高县| 盐城市|