恩有个BUTTON按钮然后添加一行

解决方案 »

  1.   

    可以动态的插入行列!
    可参考这种的:<html>
    <head>
    <script type="text/javascript">
    var isnum;
    isnum=0;function insRow()
    {
      var istemp;
      isnum+=1;
      tr1=document.getElementById('isTable').insertRow(1);  //insertRow(),里面的参数0为加在第一行,为空则加在最后一行,
      tr1.id="atr"+isnum;
      istemp="atr"+isnum;
      tr1.insertCell().innerHTML="<font color='#ff0000'>增加行"+isnum+"</font>"   ;   
      tr1.insertCell().innerHTML="<input type='text' name='txt'>";
      tr1.insertCell().innerHTML="<input type='button' onclick='delRow(\""+istemp+"\")' value='delete'>";   
    }function delRow(isthis)
    {
      isthis=document.getElementById(isthis);
      myTable=document.getElementById("isTable");
      myTable.deleteRow(isthis.rowIndex);
    }</script>
    </head><body><table id="isTable" border="1">
      <tr id="atr1">
        <td>Row1 cell1</td>
        <td>Row1 cell2</td>
        <td><input type="button" onclick="delRow('atr1')" value="delete"></td>
      </tr>
      <tr id="atr2">
        <td>Row2 cell1</td>
        <td>Row2 cell2</td>
        <td><input type="button" onclick="delRow('atr2')" value="delete"></td>
      </tr>
    </table><input type="button" onclick="insRow()" value="add"></body></html>