Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

162
Vistas
Calculation with javascript

I have a script that completes a calculation for each row of my table and then add the rows together. The calculation is alway correct if it consists of the first row only. For some reason, I'm getting an incorrect calculation when the other rows are included in the calculation.

var total = 0;
var a1 = Number(this.getField("o1i").value);
var a2 = Number(this.getField("o1iother").value);
var b1 = Number(this.getField("o2i").value);
var b2 = Number(this.getField("o2iother").value);
var c1 = Number(this.getField("o3i").value);
var c2 = Number(this.getField("o3iother").value);
var d1 = Number(this.getField("o4i").value);
var d2 = Number(this.getField("o4iother").value);
var e1 = Number(this.getField("o5i").value);
var e2 = Number(this.getField("o5iother").value);
var t = Number(this.getField("time").value);
for(var i=1; i<=15; i++){
if(this.getField("ins."+i).valueAsString == "o1" && 
this.getField("mins"+i).valueAsString != "")
total += t*a1+a2;
else if(this.getField("ins."+i).valueAsString == "o2" && 
this.getField("mins"+i).valueAsString != "")
total += t*b1+b2;
else if(this.getField("ins."+i).valueAsString == "o3" && 
this.getField("mins"+i).valueAsString != "")
total += t*c1+c2;
else if(this.getField("ins."+i).valueAsString == "o4" && 
this.getField("mins"+i).valueAsString != "")
total += t*d1+d2;
else if(this.getField("ins."+i).valueAsString == "o5" && 
this.getField("mins"+i).valueAsString != "")
total += t*e1+e2;}
if(total == 0)event.value = 0;
else
event.value = total;
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda