Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/01/2010, 07:37
Rasec101
 
Fecha de Ingreso: diciembre-2009
Ubicación: Santiago, Chile
Mensajes: 143
Antigüedad: 14 años, 4 meses
Puntos: 2
ayuda con un calculo porfavor

Tengo un formulario en php y estoy haciendo el calculo con javascript pero tengo el siguiente problema si alguien me puede ayudar por favor en el formulario hago un calculo que me arroja dos resultados que son (total_impo) y (total2) mediante un if si el total_impo es menor me haga un calculo tomando total_impo y en el else me tome total2 para la misma operación pero siempre me toma el resultado de total_impo.
No entiendo que tengo mal acá dejo el código para que alguien me eche una mano por favor. Gracias de antemano.
Código Javascript:
Ver original
  1. if(total2>total_impo)
  2. {
  3.   var calcular=document.getElementById("calcular").checked;
  4.  
  5.   document.getElementById("seguro2").value = Math.round(document.getElementById("calcular").checked ? (total2)*0.60/100: 0);
  6.  
  7. var calcular1=document.getElementById("calcular1").checked;
  8.  
  9.  document.getElementById("caja").value = Math.round(document.getElementById("calcular1").checked ? (total2)*0.60/100: 0);
  10.  
  11.  var cantidad=a.total2.value;
  12. var precio=a.imposiciones_por.value;
  13. var subt=cantidad*precio;
  14. var total=subt/100;
  15. var total1=(total-1.87)/100;
  16. //var total_general=substring(total,total.length,-2);;
  17. if (isNaN(subt))
  18. {
  19.  a.seguro.focus();
  20. }
  21. else
  22. {
  23. a.seguro.value=Math.round(total1);
  24.  
  25.  
  26. var cantidad=a.total2.value;
  27. var precio=a.por_salud.value;
  28. var subt=cantidad*precio;
  29. var total=(subt/100);
  30.  
  31. if (isNaN(subt))
  32. {
  33. a.sistema_salud.focus();
  34. }
  35. else
  36. {
  37. a.sistema_salud.value=Math.round(total);
  38. }
  39. }
Código Javascript:
Ver original
  1. else
  2. {
  3.  
  4.   var calcular=document.getElementById("calcular").checked;
  5.  
  6.   document.getElementById("seguro2").value = Math.round(document.getElementById("calcular").checked ? (total_impo)*0.60/100: 0);
  7.  
  8. var calcular1=document.getElementById("calcular1").checked;
  9.  
  10.  document.getElementById("caja").value = Math.round(document.getElementById("calcular1").checked ? (total_impo)*0.60/100: 0);
  11.  
  12.  
  13.  
  14. var cantidad=a.total_impo.value;
  15. var precio=a.imposiciones_por.value;
  16. var subt=cantidad*precio;
  17. var total=(subt/100)-seguro;
  18.  
  19. if (isNaN(subt))
  20. {
  21.  a.imposiciones.focus();
  22. }
  23. else
  24. {
  25. a.imposiciones.value=Math.round(total);
  26. }
  27.  
  28.  var cantidad=a.total_impo.value;
  29. var precio=a.imposiciones_por.value;
  30. var subt=cantidad*precio;
  31. var total=subt/100;
  32. var total1=(total-1.87)/100;
  33. //var total_general=substring(total,total.length,-2);;
  34. if (isNaN(subt))
  35. {
  36.  a.seguro.focus();
  37. }
  38. else
  39. {
  40. a.seguro.value=Math.round(total1); // Control que muestra el total
  41. }