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 originalif(total2>total_impo)
{
var calcular=document.getElementById("calcular").checked;
document.getElementById("seguro2").value = Math.round(document.getElementById("calcular").checked ? (total2)*0.60/100: 0);
var calcular1=document.getElementById("calcular1").checked;
document.getElementById("caja").value = Math.round(document.getElementById("calcular1").checked ? (total2)*0.60/100: 0);
var cantidad=a.total2.value;
var precio=a.imposiciones_por.value;
var subt=cantidad*precio;
var total=subt/100;
var total1=(total-1.87)/100;
//var total_general=substring(total,total.length,-2);;
if (isNaN(subt))
{
a.seguro.focus();
}
else
{
a.seguro.value=Math.round(total1);
var cantidad=a.total2.value;
var precio=a.por_salud.value;
var subt=cantidad*precio;
var total=(subt/100);
if (isNaN(subt))
{
a.sistema_salud.focus();
}
else
{
a.sistema_salud.value=Math.round(total);
}
}
Código Javascript
:
Ver originalelse
{
var calcular=document.getElementById("calcular").checked;
document.getElementById("seguro2").value = Math.round(document.getElementById("calcular").checked ? (total_impo)*0.60/100: 0);
var calcular1=document.getElementById("calcular1").checked;
document.getElementById("caja").value = Math.round(document.getElementById("calcular1").checked ? (total_impo)*0.60/100: 0);
var cantidad=a.total_impo.value;
var precio=a.imposiciones_por.value;
var subt=cantidad*precio;
var total=(subt/100)-seguro;
if (isNaN(subt))
{
a.imposiciones.focus();
}
else
{
a.imposiciones.value=Math.round(total);
}
var cantidad=a.total_impo.value;
var precio=a.imposiciones_por.value;
var subt=cantidad*precio;
var total=subt/100;
var total1=(total-1.87)/100;
//var total_general=substring(total,total.length,-2);;
if (isNaN(subt))
{
a.seguro.focus();
}
else
{
a.seguro.value=Math.round(total1); // Control que muestra el total
}