隨筆 - 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 飛翔天使 閱讀(2785) 評論(1)  編輯  收藏 所屬分類: javascript

          FeedBack:
          # re: 表格的折疊展開 2009-02-20 13:33 jeasonzhao
          在展開、隱藏的時候可能會導致布局錯位啊  回復  更多評論
            
          主站蜘蛛池模板: 福鼎市| 清河县| 丰镇市| 巴里| 略阳县| 定南县| 边坝县| 泸水县| 剑川县| 邓州市| 海林市| 大石桥市| 衢州市| 柞水县| 沙坪坝区| 盐边县| 顺平县| 茶陵县| 宁海县| 得荣县| 呼玛县| 南丹县| 大港区| 凤阳县| 黑水县| 高阳县| 东港市| 桐庐县| 阜新市| 宁德市| 永定县| 衡阳县| 沂水县| 阳江市| 屏山县| 绥芬河市| 原阳县| 开鲁县| 塔城市| 丹棱县| 资溪县|