Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

163
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda