Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

331
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda