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

167
Views
How do I make sure with JavaScript that when I click on the checkbox, the input field gets the number 0?

This is the gohtml code containing the checkbox and the input fields with id="number"

How do I ensure with JavaScript that when the checkbox is clicked, all the input fields are automatically entered with the number 0?

The problem is that the 0 is entered in the first field, but not in the other fields when I click on the checkbox.

Thanks in advance!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I need more than that, but for answering I am assuming your checkbox has id=chkbox

what we can do is add an event listener to the checkbox

let checkbox = document.getElementById("chkbox");
let inp = document.getElementById("number");
checkbox.addEventListener('change', function() {

  if (this.checked) {
      inp.value = 0;
  }
});

This should do the trick

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!