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

169
Vistas
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 Respuestas
Responde la pregunta

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 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