Background
I am trying to generate a variable HTML table for use with DataTables.
I've built a web viewer with a couple of selectboxes which are dependable on each other. When you select an option in "Select tabel", "Select column" changes. When you alter "Select column", "Select attribute" changes. Etc.
The results from "Select attribute" are placed in an array, which I want to use to generate the tableheaders that DataTables need.
Example:
Say myArray looks something like ["aaa", "bbb", "ccc", "ddd", "eee"], the generated report should look something like the code below.
Question
Because myArray has no fixed size and content, I can't just make a static HTML table in my index file.
How do I make a function that loops through myArray and generates a report based on the data in myArray?
Edit:
I've got my code working in JSfiddle now, however when I try to incorporate it in my web viewer code, I get an error:
The report is messed up and looks like this:
What causes this and how do I get my code to work outside of JSfiddle?
Code
<div id="report_comes_here">
<table id="report">
<thead>
<tr>
<th>aaa</th>
<th>bbb</th>
<th>ccc</th>
<th>ddd</th>
<th>eee</th>
</tr>
</thead>
</table>
</div>
