var innerHtml = "";
var objTr = createTr(rowNo);
var objTd_8 = createTd("100%", "number", null);
innerHtml = span("spanQuantity" + rowNo, quantity)
+ '<input type="text" name="' + listNm + '[' + rowNo + '].nm" value="' + quantity + '">';
objTd_8.innerHTML = innerHtml;
objTr.appendChild(objTd_8);
objTable.firstChild.appendChild(objTr);只是一个思路,怎么写忘记了!

解决方案 »

  1.   

    是否可以用js来做啊?
      
    -------------------------------------------
    MSN:[email protected] 
    请给我与您交流的机会
      

  2.   

    <table id="table1"  border="1">
    <tr style="display:none"><td><input></td><td><input type="button" value="删除" onclick="this.parentNode.parentNode.removeNode(true)">
    </tr>
    <tr><td><input></td><td><input type="button" value="删除" onclick="this.parentNode.parentNode.removeNode(true)">
    </tr>
    <tr><td><input></td><td><input type="button" value="删除" onclick="this.parentNode.parentNode.removeNode(true)">
    </tr>
    </table>
    <input name="aaa" type="button" value="新增" onclick=addRow()>
    <script language=javascript>
    function addRow(){
    var objTbody=document.getElementById("table1").childNodes[0]
    var objNewTr=objTbody.childNodes[0].cloneNode(true)
    objNewTr.style.display=""
    objTbody.appendChild(objNewTr)
    }
    </script>
      

  3.   

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="932"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
    <title>Untitled Document</title>
    </head><body>
    <form name="form1" method="post" action="" id="form1"><input type="button" name="Button" value="Button" onClick="bbb()" id="aa"><input type="button" name="Button" value="Button" onClick="xxx()" id="bb"></form>
    </body>
    </html>
    <script language="javascript"></script>
    <script language="vbscript">
    function bbb()
    set aaa=document.createElement("input")
    aaa.type="text"
    aaa.name="textfield"
    document.form1.appendChild(aaa)
    end function function xxx()
    set obj =document.getelementbyid("form1")
    for i=0 to obj.childnodes.length-1
    if  obj.childnodes(i).name="textfield" then
    obj.removechild(obj.childnodes(i))
    exit function
    end if 
    next 
    end function 
    </script>
      

  4.   

    晕javascript哈哈楼主稍微改一下就行
      

  5.   

    还是hbhbhbhbhb1021(天外水火(我要多努力))的好
      

  6.   

    IE FF 过:<script type="text/javascript">
    function addT(){
    var inps=document.getElementById("inps");
    var div=document.createElement("div");
    var inp=document.createElement("input");
    inp.setAttribute("type","text");
    but=document.createElement("input");
    but.setAttribute("type","button");
    but.setAttribute("value","删除");
    but.par=inps;
    but.onclick=function(){
    this.par.removeChild(this.parentNode);
    }
    div.appendChild(inp);
    div.appendChild(but);
    inps.appendChild(div);
    }
    </script>
    <div id="inps"></div>
    <input type="button" value="增加" onclick="addT()" />
      

  7.   

    感谢大家。。楼上的几个我试过了都是可以的。。不过我想问下cgisir(☆☆☆===http://www.hansir.cn===☆☆☆) 和hbhbhbhbhb1021(天外水火(我要多努力)) ,就是怎么设置这些input框的name?不然我没法往数据库里存数据啊-。-
      

  8.   

    取的时候第一个aaa不要
    <table id="table1"  border="1">
    <tr style="display:none"><td><input name="aaa"></td><td><input type="button" value="删除" onclick="this.parentNode.parentNode.removeNode(true)">
    </tr>
    <tr><td><input name="aaa"></td><td><input type="button" value="删除" onclick="this.parentNode.parentNode.removeNode(true)">
    </tr>
    <tr><td><input name="aaa"></td><td><input type="button" value="删除" onclick="this.parentNode.parentNode.removeNode(true)">
    </tr>
    </table>
      

  9.   

    谢谢楼上的兄弟。。不过按你的做法。。这些input框的name 都一样,我没法往数据库里存啊~
    还有怎么限定新增的最大值(比如最多新增10个)
      

  10.   

    创建input的时候这样
    var inp=document.createElement("<input name='xxx'>");
      

  11.   

    楼上的。。打个比方,如果建10个框框,怎么确定name是name1到name10
    这样的循环语句咋写啊(考虑到中间有框被删除,然后又添加的情况)。。>.<
      

  12.   

    <script type="text/javascript">
    var i=0;
    function addT(){
    var inps=document.getElementById("inps");
    var div=document.createElement("div");
    var inp=document.createElement("input");
    inp.setAttribute("type","text");//类型
    inp.setAttribute("name","text"+i);//这里可以设置name 看你想做什么了
    inp.setAttribute("value","name=text"+i);//这里可以设置初始值
    but=document.createElement("input");
    but.setAttribute("type","button");
    but.setAttribute("value","删除");
    but.par=inps;
    but.onclick=function(){
    this.par.removeChild(this.parentNode);
    }
    div.appendChild(inp);
    div.appendChild(but);
    inps.appendChild(div);
    i++;
    }
    </script>
    <div id="inps"></div>
    <input type="button" value="增加" onclick="addT()" />
      

  13.   

    function test(){
    var inp=document.createElement("<input name='" + document.uniqueID + "'>");
    inp.value = inp.name;
    document.body.appendChild(inp)
    }<input type="button" value="oooo" onclick='test()' />
      

  14.   

    可是使用js的innerHTML或者createElement来实现,至于你说的name和个数什么的,那都是小问题,自己想一下。做个全局变量什么的,按照一定规则来生成不就行了。不明白你具体的业务逻辑,还有什么要求可以跟我联系
      

  15.   

    cgisir(☆☆☆===http://www.hansir.cn===☆☆☆) 请问下,这里怎么限制新增input框的数量?
      

  16.   

    因为有个全局变量i
    判断i的值就行了
    比如你想最多增加10个,就在addT()的开始判断一下,下边的内容不变
    function addT(){
    if(i==10){
     return;
    }
    //
    ...
    }