瘋狂

          STANDING ON THE SHOULDERS OF GIANTS
          posts - 481, comments - 486, trackbacks - 0, articles - 1
            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          仍一個(gè)能增減行的javascript

          Posted on 2007-10-08 18:52 瘋狂 閱讀(256) 評(píng)論(0)  編輯  收藏

          <html><head>
           <script language="javascript">
               var rowIndex = 0;
               function addOneLineOnClick() {
                   var row=tb.insertRow(tb.rows.length);
                          col = row.insertCell(0);
                          col.innerHTML = "<tr><input size='90'  name=btn index=\""+ rowIndex +"\" >";
                          col = row.insertCell(1);
                          col.innerHTML = "<input type='button' value='刪除'  onclick=\"return DeleteRow('row" + rowIndex +"')\"></tr>";
                         row.setAttribute("id", "row" + rowIndex);
                         row.setAttribute("name", "row" + rowIndex);
                         rowIndex++;
             }
           function DeleteRow(rowTag){
                         var i = tb.rows(rowTag).rowIndex;
                         var j;
                         for(j=i;j<=rowIndex;j++) { 
                         tb.rows(j).cells(0).all("btn").index--; 
            }
                         tb.deleteRow(i);
                         rowIndex--;
           }

          </script>
          </head>
          <body >
            <div align="center">
                <table width="95%" name="tb" id="tb">
            <tr>
            </tr>
                </table>
           <p>
           <input name="btnAddLine" type="button" id="btnAddLine" onClick="return addOneLineOnClick()" value="加入一行">
           </div>
          </body>
          </html>


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 山阴县| 呼玛县| 工布江达县| 阿拉善右旗| 阳信县| 安远县| 伊通| 大渡口区| 泰来县| 香格里拉县| 怀安县| 万源市| 板桥市| 邓州市| 临夏市| 峨山| 榆树市| 平泉县| 湾仔区| 房山区| 抚顺县| 彩票| 高雄市| 贵州省| 三台县| 许昌县| 浦城县| 马公市| 昭平县| 双鸭山市| 昌平区| 玉山县| 富平县| 新干县| 榕江县| 沽源县| 满洲里市| 沅陵县| 姚安县| 涿鹿县| 东丰县|