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

330
Vistas
How to display array data inside textbox using loop? (One textbox per array data)

Good day! I badly need help for this one, I have an array with many elements/data that is needed to be display in textbox. Each array element/data must be inside the textbox. (The Textbox must be dynamically set up using loop with the array data inside it)


                    
                        arr = ["1"-"2"-"3"-"4"-"5"]; //my array is from the db, this is example only
                        conv_arr = arr.split("-")
                        
                        var myArray = [conv_arr];
                        
                        var ArrayInText = document.createElement('input');

                        myArray.forEach(function(conv_arr) {

                        ArrayInText.value = conv_arr ;
                        
                        document.body.appendChild(ArrayInText);

It displays the array (pretend this is a textbox [ ]) [ 1, 2, 3, 4, 5 ]

I want a result that looks like this (One textbox per element using loop) [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ]

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can see the demo here=> https://jsfiddle.net/4ow6k8j5/1/

After removing unnecessary assignments, you can use below simplest solution;

conv_arr = arr.split("-")

conv_arr.forEach(function(elem) {
  var ArrayInText = document.createElement('input');
  ArrayInText.value =  elem ;
  document.body.appendChild(ArrayInText);
});
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