Código HTML:
<html> <head> <script> var parametro; function popup(num) { parametro = window.open("copia1.php?id="+ num,"","width=400,height=500,toolbar=0,scrollbars=1,left = 450,top = 0"); } </script> <script language=javaScript1.2> var numero=1; function suma(){ var miTabla = document.getElementById("cuerpoTabla"); var lasCeldas = miTabla.getElementsByTagName("tr"); var fila = document.createElement("tr"); var celda1 = document.createElement("td"); var celda2 = document.createElement("td"); var celda3 = document.createElement("td"); celda1.innerHTML = "<input type='text' name='fechas1[]' size='8' maxlength='10'>"; celda2.innerHTML = "<input type='text' name='descripcion[]' size='30' id='resul_<? echo ++$i;?>' readonly><img src='fotos/visualizar.gif' name='ayuda' width='21' height='21' border='0' onclick='popup(<? echo $i;?>)' alt='Ver Lista Insumos'>"; celda3.innerHTML = "<input type='text' name='cantidad[]' size='3' maxlength='4'>"; fila.appendChild(celda1); fila.appendChild(celda2); fila.appendChild(celda3); miTabla.appendChild(fila); alert(+numero); } </script> </head> <body> <TABLE id=unaTabla style="BACKGROUND-POSITION: center center; BACKGROUND-REPEAT: no-repeat" border=1> <TBODY id=cuerpoTabla> <TR id=a1 align="center"> <TD id=b1><input type="text" name="fechas1[]" size="8" maxlength="10"></TD> <TD id=c1><input type="text" name="descripcion[]" size="30" id="resul_<? echo ++$i;?>" readonly><img src="fotos/visualizar.gif" name="ayuda" width="21" height="21" border="0" onclick="popup(<? echo $i;?>)" alt="Ver Lista Insumos"></TD> <TD id=h1 align="center"><input type="text" name="cantidad[]" size="3" maxlength="4"></TD> </TR> <TR id=a2 align="center"> <TD id=b2><input type="text" name="fechas1[]" size="8" maxlength="10"></TD> <TD id=c2><input type="text" name="descripcion[]" size="30" id="resul_<? echo ++$i;?>" readonly><img src="fotos/visualizar.gif" name="ayuda" width="21" height="21" border="0" onclick="popup(<? echo $i;?>)" alt="Ver Lista Insumos"></TD> <TD id=h2 align="center"><input type="text" name="cantidad[]" size="3" maxlength="4"></TD> </TR> </TBODY></TABLE><input type="submit" name="enviar" value="Procesar Planilla" class="texto"><BUTTON onclick=suma()>sumar</BUTTON></center> </td> </tr> </table> </body> </html>