用隐藏控件把动态加的数据提交。有的也不
用的,如text,只要他们的名字一样,提交后能得到数组(php),
就不用隐藏控件,显示的时候就是你控制的问题了

解决方案 »

  1.   

    简单点的做法,页面 onunload 的时候把新加的文本框及value丢到cookie里去,onload的时候把这些信息重现在页面上。
      

  2.   


    前台页面page1.html:
     <FORM action="Page2.asp" method=POST id="form1">
    <table id="myTable">
    <tr >
    <td id="myTd1">
    <INPUT type="text" name="text1">内容
    </td>
    </tr>
    </table>
    <br/>
    <button  onclick="doAdd();" >AddRow</button>
    <button  onclick="doDel();" >DelRow</button>
    <button  onclick="form1.submit();">OK!</button>
    </FORM>
     
    <script>
    var i=0;
    function doAdd()
    {
    i=i+1;
    var nowTable=document.all.myTable;
    var newTr=nowTable.insertRow(i);
    var newTd=newTr.insertCell(0);
    newTd.innerHTML =myTd1.innerHTML;

    //假设名字是随便取的
    newTd.getElementsByTagName("INPUT")[0].setAttribute("name","text" + parseInt( Math.random() * 100));

    //可以用下面这行测试新名字
    alert( newTd.getElementsByTagName("INPUT")[0].getAttribute("name"));
    //getAttribute("name"));
     
    }
    function doDel()
    {
    if(i>=1)
    {
    document.all.myTable.rows(i).removeNode();
    i=i-1;
    }
    else
    {
    alert("不能全删光!");
    }
    }
    </script>
     
    后台页面page2.asp:
    <%
     
     for each myInput in Request.Form
      Response.Write myInput  
      Response.Write "="  
      Response.Write  Request(myInput) 
      Response.Write  "<br/>"
     next
    %>