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

329
Views
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 answers
Answer question

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