how do i build a table dynamically in this scenario

I have a variable which contains an array of arrays. It is parsed code from … Read more how do i build a table dynamically in this scenario

I have a variable which contains an array of arrays. It is parsed code from an excel file.

I want to upload my file and build the table, ive tried it like this:

tabela.forEach((elem, index) => {
  console.log(elem[0], index[1])
  const row = tableBody.insertRow(index)
  const employeeCell = row.insertCell(0)
  let content = document.createTextNode(elem[0])
  employeeCell.appendChild(content)
})

and like this:

for (let i = 1; i < tabela.length; i++) {
  const row = tableBody.insertRow(tabela[1])
  const employeeCell = row.insertCell(0)
  let content = document.createTextNode(tabela[0])
  employeeCell.appendChild(content)
}

but I get strange results with both.

I really want to understand what Im doing but am having issues.

The variable tabela is an array of 13 elements, each element is an array with 7 elements.

does anybody know what im doing wrong how to make it so i build a whole table from the parsed code from "tabela" variable?

Source: JavaSript – Stack Overflow


Categories: NewsTags: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *