I am new to Javascript. I am using a counter to determine the structure of a table.
I have tried to create a logic function that when the counter is 0, create a row. If the counter is between 1-6 create a table header within the row. If the counter is greater than 6 reset the counter to 0.
Thanks
<script>
var counter = 0;
function addRow(v_id, t_id) {
"use strict";
var tableBody = document.getElementById(t_id);
var td1 = document.createElement("td");
var row = document.createElement("tr");
var col = document.createElement("cols");
td1.innerHTML = document.getElementById(v_id).innerHTML;
row.appendChild(td1);
tableBody.appendChild(row);
}
</script>
<script>
function t1 (var counter) {
//Add row
if (counter === 0)
{document.createElement("tr")}
//Add th
else if (counter === 1-6)
{document.createElement("th")}
//Counter reset
else if (counter >6)
{counter = 0}
}
</script>
Aucun commentaire:
Enregistrer un commentaire