谁能帮我实现啊,大概意思 是
点击增加按钮, 然后下面多出一列文本框,旁边再显示删除。再点击增加按钮,下面又多出一列文本框,旁边再显示删除,点击删除按钮,就能把这一列删除掉,大概思路是 creatElement("input")  a.type=text,以前写过,现在忘了,谁能帮我写个完整的代码啊。正线急等。

解决方案 »

  1.   

    不要用这种方式document.getElementById('addtable').insertRow(-1);。因为不是表格
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script type="text/javascript">
    var test={
    'tbody':'',
    'num':1,
    'add':function(){
    if(!this.tbody){
    this.tbody=document.getElementById("test");
    }
    var text=document.createElement("input");
    text.type='text';
    text.value=this.num++;
    var button=document.createElement("input");
    button.type='button';
    button.value='删除';
    var tr=document.createElement("tr");
    var tdt=document.createElement("td");
    var tdb=document.createElement("td");
    tdt.appendChild(text);
    tdb.appendChild(button);
    tr.appendChild(tdt);
    tr.appendChild(tdb);
    this.tbody.appendChild(tr);
    var me=this;
    button.onclick=function(){
    me.tbody.removeChild(tr);
    }
    }
    }
    </script>
    </head><body>
    <input type="button" value="add" onclick="test.add()">
    <table>
    <tbody id="test"></tbody>
    </table>
    </body>
    </html>
    这样试试
      

  3.   

    不知有没有理解错你意思 <input type="button" value="添加" onclick="add(this)">
    <div id="inputs" ></div>
     <script type="text/javascript">
       var inputs=document.getElementById('inputs');
       function add(el){
        if(el.value=='添加'){
        inputs.innerHTML="<input name='txt' /><br/><input name='txt' /><br/><input name='txt' /><br/><input name='txt' /><br/>"
          el.value='删除'
        }else{
        el.value='添加'
        inputs.innerHTML='';
        }
       }
    </script>