Ver Mensaje Individual
  #17 (permalink)  
Antiguo 13/01/2016, 15:14
jmg1189
 
Fecha de Ingreso: septiembre-2015
Mensajes: 58
Antigüedad: 8 años, 7 meses
Puntos: 2
Respuesta: ejecutar funcion al cargar pagina

Cita:
Iniciado por Alexis88 Ver Mensaje
Revisa con calma cada línea y haz las correcciones respectivas.
Tal vez a alguien le pueda servir, pude solucionarlo modificando la función y así me quedó:

Código Javascript:
Ver original
  1. function calculo_impu(){
  2.                 var total = $("#total").val(), descuento = $("#descuento").val(), vrdescuento = $("#vrdescuento").val(),
  3.                 totalD = $("#totalD").val(), vriva = $("#vriva").val(), iva = $("#iva").val(),
  4.                 vrretefuente = $("#vrretefuente").val(), retefuente = $("#retefuente").val(), vrica = $("#vrica").val(),
  5.                 reteica = $("#reteica").val(), totalG = $("#totalG").val();
  6.                 if(total==""){ total.value=0; }
  7.                 if(descuento==""){ descuento.value=0; }
  8.                 var Dcto = ((parseFloat(total)*parseFloat(descuento))/100).toFixed(2);
  9.                 if(Dcto==''){ Dcto.value=0; }
  10.                 $("#vrdescuento").val(Dcto);
  11.                 var totalD1=(parseFloat(total)-Dcto).toFixed(2);
  12.                 $("#totalD").val(totalD1);
  13.                 if(vriva=="") { vriva.value=0; }
  14.                 if(iva==""){ iva.value=0; }
  15.                 var iva1 =((totalD1*parseFloat(vriva))/100).toFixed(2);
  16.                 $("#iva").val(iva1);
  17.                 if(vrretefuente==""){  vrretefuente.value=0; }
  18.                 if(retefuente==""){  retefuente.value=0; }
  19.                 var retefuente1 =((totalD1*parseFloat(vrretefuente))/100).toFixed(2);
  20.                 $("#retefuente").val(retefuente1);
  21.                 if(vrica=="") { vrica.value=0; }
  22.                 if(reteica=="") { reteica.value=0; }
  23.                 var reteica1=((totalD1*parseFloat(vrica))/100).toFixed(2);
  24.                 $("#reteica").val(reteica1);
  25.                 if(totalG==""){ totalG.value=0; }
  26.                 var totalG1=(parseFloat(totalD1)+parseFloat(iva1)-parseFloat(retefuente1)-parseFloat(reteica1)).toFixed(2);
  27.                 $("#totalG").val(totalG1);
  28.             }
  29.             $(document).ready(function(){
  30.                 calculo_impu();
  31.             });

al final invoco la función cada que a pagina se recargue.
Gracias a todos por su ayuda.