用javascript动态添加和删除文本框

用javascript动态添加和删除文本框
  1. <script   language="javascript">                                   
  2.   function   add()                                   
  3.   {   
  4.         option   =   new   Array();   
  5.         proportion   =   new   Array();                           
  6.         str='';   
  7.         strstr=str+'<tr   align=center   valign=middle   bgcolor=#FFFFFF>';   
  8.         strstr=str+'<td   width="100%"   height="25"><input   type="text"   name=proportion>td>';   
  9.         strstr=str+'<td   width="100%"   height="25"><input   type="button"   name=del   onclick="this.parentNode.parentNode.parentNode.deleteRow(this.parentNode.parentNode.rowIndex)"   value="删除">td>';   
  10.         strstr=str+'tr>table>';   
  11.         window.upid.innerHTML+=str+'';   
  12.   }                                   
  13.   script>   
  14.   <html>   
  15.   <head>   
  16.   <title>Untitled   Documenttitle>   
  17.   <meta   http-equiv="Content-Type"   content="text/html;   charset=gb2312">   
  18.   head>     
  19.   <body>       
  20.   <form   name="myform"   onsubmit="javascript:return   check()">       
  21.         <table>       
  22.                 <tr>           
  23.                         <td>     
  24.                                 <input   name="Submit2"   type="button"   onclick="javascript:add()"   value="增加">       
  25.                         td>           
  26.                 tr>           
  27.                 <tr>               
  28.                         <td>           
  29.                         <div   id="upid">div>       
  30.                         td>           
  31.                 tr>     
  32.         table>                                   
  33.   form>                                   
  34.   body>                                   
  35.   html>  
  36. 你可能感兴趣的:(HTML,JS)