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

99
Vistas
Is there anyway to make this code faster?

I have a code here that automatically tick a box when all three boxes are true, however this is taking forever to load as I have thousands of boxes in the sheet, is there any way to make this code quicker?

at the moment the code is making everything lag and unresponsive

function checkBox(j,k,l,m,result){ 
 
  var result = true;

  if ( j === true && k === true & l === true && m === true) {
    result = true;
  } else {
    result = false;
  }

  return result;

}

if the first four boxes are tick, then box number 6 will automatically tick, but it's taking forever to load

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Not sure what you are doing wrong, but this code took 46ms for 10,000 lines - a little longer to render on the screen.

function go(){

    //set up a test table with every 10th row with all boxes ticked
    let str="<table>";
    for (let i=0;i<10000;i++){
        str +="<tr>";
        for (let j=0;j<4;j++){
            str +="<td><input type='checkbox'></td>";
        }
        str +="<td> </td><td><input type='checkbox'</td>";
        str +="</tr>";
    }
    str +="</table>";

    container.innerHTML=str;


    //start here to compute the result column

    let start=(new Date()).getTime();
    let table=container.querySelector("table");
    let rows=table.querySelectorAll("tr");

    for (let i=0;i<rows.length;i++){
        let inputs=rows[i].querySelectorAll("input");
        if(i%10==0){
            for (let j=0;j<4;j++)inputs[j].checked=true;
        }
        else {
            for (let j = 0; j < 4; j++) {
                if (Math.random() < 0.5) inputs[j].checked = true;
            }
        }
        inputs[4].checked=inputs[0].checked && inputs[1].checked && inputs[2].checked && inputs[3].checked;
    }

    alert((new Date()).getTime()-start);
}
about 4 years ago · Juan Pablo Isaza Denunciar
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