<script type ="text/javascript" >   
      function addFiles(oContainer)   
        {         
          var   sLineHTML="<div><input  id='INTO'  type='text'   name='"+ +"'   style='width:400'</div>";   
          oContainer.insertAdjacentHTML('beforeEnd',sLineHTML);   
        }                   
 </script>
<body>
    <form id="form1" runat="server">
        <div>
        <table   >   
  <tr>   
  <td   id="TD"   colspan="2"><FONT   face="宋体"></FONT></td>   
  </tr> <tr>   
  <td   colspan="2">   
  <div   align="left"><font   size="2"></font><input   onclick="javascript:addFiles(TD);"   type="button"   value="添加"   name="button"/>   
  </div>   
  </td>   
  </tr>   
  </table>   
        </div>
    </form>
</body>
代码是这样的。但是我想了一下,这样的话每次添加的文本框的Name属性都一样。所以无法取到添加的多个文本框的值。请高手指点一下吧。我现在真的急用

解决方案 »

  1.   

    1.name可以一样,但id不能一样。看你的代码,你给弄拧了!
    2.id可以用id="info_"+随机数来区分。
      

  2.   

        <script type ="text/javascript" > 
        var iText = 0;
          function addFiles(oContainer) 
            {  
                     
              var  sLineHTML=" <div> <input  id='INTO'  type='text'  name='Text"+ iText +"'  style='width:400' </div>"; 
               iText++;
              oContainer.insertAdjacentHTML('beforeEnd',sLineHTML); 
            }                 
    }
    </script>
      

  3.   

    document.getElementById("name"+随机数).value
    当然文本框也是动态建立的.
      

  4.   

    <html>  
      <body>  
      <form  name="form1">  
      <table  id="tb1"  border=0>  
            <tr> <td> <a  href="#"  onclick="return  addFj()">增加 </a> </td> </tr>  
      </table>  
      <input  type="hidden"  name="fjCnt"  value="1"  />  
      </form>  
      </body>  
      </html>  
      <script  language="javascript">  
          function  addFj()  
          {  
                  var  oTb  =  document.getElementById("tb1");  
                  var  oTr  =  oTb.insertRow(0);  
                  var  name  =  "thefilename"+document.form1.fjCnt.value;  
                  document.form1.fjCnt.value=parseInt(document.form1.fjCnt.value)+1;  
                  oTr.insertCell(0).innerHTML  =  " <input  id='file'  name='"+name+"'  type=text  style='width:400px;'>  <input  type=button  onclick='return  delFj(this)'  value='删除'>"  
                  return  false;  
          }  
          function  delFj(obj)  
          {  
                  obj.parentElement.parentElement.removeNode(true);  
                  return  false;  
          }  
      </script>