I am trying to populate the array data into html using google apps script.
I have given a lot of time to troubleshoot the problem but could not find whats missing:-
HTML Tags :-
<table class="highlight">
<thead>
<tr>
<th>Delta</th>
<th>Assigned</th>
<th>Reviewed</th>
<th>Pending</th>
</tr>
</thead>
<tbody id="perf">
</tbody>
</table>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<?!= include('table1-js'); ?>
Javascript:-
<script>
var data = [
[1,2,3,4]
[5,6,7,8]
[9,10,11,12]
[9,10,11,12]
];
document.addEventListener('DOMContentLoaded', function(){
getTable1Data(data);
});
function getTable1Data(dataArray){
var tbody = document.getElementById('perf');
dataArray.forEach(function(r){
var row = document.createElement("tr");
var col1 = document.createElement("td");
col1.textContent = r[0];
var col2 = document.createElement("td");
col2.textContent = r[1];
var col3 = document.createElement("td");
col3.textContent = r[2];
var col4 = document.createElement("td");
col4.textContent = r[3];
row.appendChild(col1);
row.appendChild(col2);
row.appendChild(col3);
row.appendChild(col4);
tbody.appendChild(row);
});
}
</script>
Currently the result is only the Heading displayed in HTML and there is no data that is being appended into the table.