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

122
Views
Using an array as the text content

I am trying to create a system to place a the values of the array into the text.

Array:

var records = [
    ['C', 'Descript']
    ['D', 'Test']
];

Creates the 'th' that I want to put the array values in.

let newColItem = document.createElement('th');

What I have tried:

galleryheader.textContent = records[i,1];

The i is from a for loop. No values a showing in the galleryheader cell. I can't find anything on how to put the array inside on the web, anyone got some idea of what to do.

All code if you need it:

const gallery_table = document.getElementById("gallery_table");
let list = ["A", "B"];
var idName = "";
var records = [
    ['C', 'Descript']
    ['D', 'Test']
];

for (let i = 0; i < list.length; i++) {
    if (i % 3 === 0) {
        var newRowItem = document.createElement("tr");
        idName = "newRowItem";
        idName = idName.concat(i);
        newRowItem.setAttribute("id", idName);
        gallery_table.appendChild(newRowItem);
    }
    let newColItem = document.createElement('th');
    let galleryheader = document.createElement('h3');
    newColItem.setAttribute("class", i);    
    newRowItem.appendChild(newColItem);
    newColItem.appendChild(galleryheader);
    galleryheader.textContent = records[i,1];


    const element = document.getElementById(idName);
    let nodes = element.getElementsByClassName(i);
    for (let j = 0; j < nodes.length; j++) {
        nodes[j].style.padding = "2px";
        nodes[j].style.width = "33%";
        nodes[j].style.border = "1px solid black";
    }
}
about 4 years ago · Juan Pablo Isaza
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!