function add()
{
document.writeln("<input type='text' name='textfield'>");
}
上面的name属性可以用参数的。
取消一个好像比较困难,还没想到办法。

解决方案 »

  1.   

    <form>
    <input type="button" onclick="addline()" value="增加">
    <table border="1" id="test">  
      <tr>
        <td colspan="2"><input type="text" name="tt[]"></td>
      </tr>
    </table>
    <input type="submit">
    </form>
    <script>
    function addline(content){
    newline=document.all.test.insertRow();
    newline.insertCell().innerHTML='<input type="text" name="tt[]"><input type="button" value="删除此行" onclick="del()">'}
    function del(){
    document.all.test.deleteRow(window.event.srcElement.parentElement.parentElement.rowIndex);
    }
    </script>