Ver Mensaje Individual
  #2 (permalink)  
Antiguo 01/04/2016, 09:15
infoturnosya
 
Fecha de Ingreso: diciembre-2015
Ubicación: rosario
Mensajes: 69
Antigüedad: 8 años, 5 meses
Puntos: 5
Respuesta: error al sumar autosuma

La verdad tenes un lio importante y es muy complicado explicarlo asi q te pego el codigo derecho, de lo que creo querias hacer, si necesitas saber mas avisa
Código Javascript:
Ver original
  1. $(document).ready(function(){
  2.     function sumarImportes(){
  3.         var total = 0;
  4.  
  5.         $('input.importe').each(function(index){
  6.             total += parseFloat($(this).val()?$(this).val():0);
  7.         });    
  8.         $('#amt_due').val(total.toFixed(2));
  9.     }
  10.    
  11.    
  12.     var max_fields = Infinity; //maximum input boxes allowed
  13.     var wrapper1 = $(".input_fields_wrap1");
  14.     var add_button1 = $(".add_field_button1"); //Add button
  15.  
  16.     var x = 0; //initlal text box count
  17.     $(add_button1).click(function(e){ //on add input button click
  18.         e.preventDefault();
  19.         if(x < max_fields){ //max input box allowed
  20.             x++; //text box increment
  21.             $(wrapper1).append('<div id="contenedor"><input type="text" value="'+x+'" size="5">&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="prod['+x+'][detalle]" size="60"/> N/S: <input type="text" name="prod['+x+'][serie]" size="40"/> P.Unit: <input type="text" name="prod['+x+'][cantidad]" class="importe" size="10"/><input class="remove_field" type="button" value="- Eliminar" /></div>'); //add input box
  22.         }
  23.        
  24.     });
  25.  
  26.     $(wrapper1).on("click",".remove_field", function(e){ //user click on remove text
  27.         e.preventDefault();
  28.         $(this).parent('div').remove();
  29.         sumarImportes();
  30.         x--;
  31.     });
  32.  
  33.     $(wrapper1).on("blur","input.importe", function(e){
  34.         sumarImportes();
  35.     });
  36. });