Ver Mensaje Individual
  #2 (permalink)  
Antiguo 22/05/2012, 11:05
Avatar de djaevi
djaevi
 
Fecha de Ingreso: marzo-2007
Ubicación: Moreno, Buenos Aires
Mensajes: 400
Antigüedad: 17 años, 11 meses
Puntos: 47
Respuesta: javascript- formulario- crear nuevo

Hola me resulto interesante tu trabajo asi que lo corregi un poco fijate si te sirve y si te hace falta cambiarle algo me avisas ;).

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>Documento sin t&iacute;tulo</title>
  5.  
  6. <script type="text/javascript">

Código Javascript:
Ver original
  1. function clon(e) {
  2.     var cantForms = document.getElementsByName("FacProvForm").length;
  3.     var clon = e.parentNode.cloneNode(true);
  4.         clon.Eliminar.onclick = function() {
  5.             document.body.removeChild(this.parentNode);
  6.         }
  7.     clon.calcular = e.parentNode.calcular;
  8.     clon.cantidad.value = 0;
  9.     clon.costo.value = 0;
  10.     clon.subtotal.value = 0;
  11.     clon.PcioVta.value = 0;
  12.     clon.gcia.value = 0;
  13.     document.body.appendChild(clon);   
  14. }
  15.  
  16. function assign() {
  17.     document.forms[0].calcular = function() {
  18.         this.Vcantidad = this.cantidad.value;
  19.         this.Vcosto = this.costo.value;
  20.         this.Vsubtotal = this.subtotal.value = (this.Vcantidad * this.Vcosto) ;
  21.         this.VPcioVta = this.PcioVta.value;
  22.         this.Vgcia = this.gcia.value = (((this.VPcioVta / this.Vcosto)-1)*100) ;
  23.     }
  24.     //alert(document.forms[0].calcular);
  25. }

Código HTML:
Ver original
  1.  
  2. </head>
  3.  
  4. <body onload="assign();">
  5.  
  6. <form name="FacProvForm">
  7. <input name="cantidad" type="text" onkeyup="this.parentNode.calcular()" size="15" value="0">
  8. <input name="costo" type="text" onkeyup="this.parentNode.calcular()" size="15" value="0">
  9. <input name="subtotal" type="text" onkeyup="this.parentNode.calcular()" size="15" value="0">
  10. <input name="PcioVta" type="text" onkeyup="this.parentNode.calcular()" size="15" value="0">
  11. <input name="gcia" type="text" onkeyup="this.parentNode.calcular()" size="15" value="0">
  12. <input name="Agregar" type="button" onClick= "clon(this);" value="Agregar Item" />
  13. <input name="Eliminar" type="button" value="Eliminar Item" />
  14. </form>
  15.  
  16. </body>
  17. </html>

Ahora mismo me estoy yendo si necesitas que te explique como funciona el codigo me avisas

SALUDOS