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

jsp页面兑现行的增加,删除

2012-10-29 
jsp页面实现行的增加,删除%@ page contentTypetext/html charsetGBK %htmlheadscript typet

jsp页面实现行的增加,删除
   <%@ page contentType="text/html; charset=GBK" %>
   <html> 
   <head> 
   <script type="text/javascript"> 
   function deleteRow(r) 
   { 
   var i=r.parentNode.parentNode.rowIndex 
   document.getElementById('myTable').deleteRow(i) 
   } 
    
   function insertRowInTable(){ 
   var table = document.getElementById("myTable"); 
   var newRow = table.insertRow(-1); 
   newRow.insertCell().innerHTML = "Row " +(newRow.rowIndex+1); 
   newRow.insertCell(-1).innerHTML = "<input type='button' value='删除' onclick='deleteRow(this)'>"; 
   } 
   </script> 
   </head> 
   <body> 
    
   <table id="myTable" border="1"> 
   <tr> 
   <td>Row 1</td> 
   <td><input type="button" value="删除" onclick="deleteRow(this)"></td> 
   </tr> 
   <tr> 
   <td>Row 2</td> 
   <td><input type="button" value="删除" onclick="deleteRow(this)"></td> 
   </tr> 
   <tr> 
   <td>Row 3</td> 
   <td><input type="button" value="删除" onclick="deleteRow(this)"></td> 
   </tr> 
   </table> 
   <input type="button" onclick="insertRowInTable();" value="插入一行" /> 
   </body> 
   </html> 

热点排行
Bad Request.