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";
}
}