Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

96
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!