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

113
Vistas
html input element will not update to for loop

The text in the input immediately just skips to 99. Is there any way I can make it display the i variable, while it's iterating?

<input id="test" type="text">
<script>
    for(let i = 0; i < 100; i++){
    document.getElementById("test").value = String(i);
  }
</script>

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can use setInterval to call your function at whatever interval you like:

let i = 0;
setInterval(function() {
  if (i < 100) {
    document.getElementById("test").value = String(i);
    i++;
  }
}, 100)
<input id="test" type="text">

Your way won't work without some sort of delay because the entire loop executes in milliseconds and is too fast for the eye to see.

about 4 years ago · Santiago Trujillo 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