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

123
Vistas
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
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