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

182
Views
Valor de incremento JS para cada clic después de verificar si es verdadero

Quiero verificar si todas las casillas de verificación están marcadas.

Para esto, obtuve este código:

 bind() { this.checks = document.getElementsByClassName("checkdoc"); const len = this.checks.length; this.validCheckbox = 0; for (let i = 0; i < len; i++) { this.checks[i].onclick = this.updateValid; } if (this.validCheckbox === len) { this.allChecked = true; this.update(); } } updateValid() { if (this.checked === true) { this.validCheckbox += 1; } else { this.validCheckbox -= 1; } console.log(this.validCheckbox); }

Pero no funciona porque this.validCheckbox es NaN tan indefinido. Si lo agrego como parámetros en this.updateValid así:

 this.updateValid(this.validCheckbox) ... updateValid(nb) { if (this.checked === true) { nb += 1; } else { nb -= 1; } console.log(nb); return nb; }

Primero, mi console.log me da -1 en el segundo método, luego no puedo hacer varias llamadas. Si hago clic en la primera casilla de verificación, no pasa nada porque al cargar, se realiza la primera llamada. Si tienes algún consejo, lo tomaré.

about 4 years ago · Juan Pablo Isaza
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!