I am creating an invoice website for my intranet.
I have the following code for making a dynamic table row inside the html that generates rows up to how much we need for the invoice.
function addRow(tableID) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var colCount = table.rows[1].cells.length;
for(var i=0; i<colCount; i++) {
var newcell = row.insertCell(i);
newcell.innerHTML = table.rows[1].cells[i].innerHTML;
//alert(newcell.childNodes);
switch(newcell.childNodes[0].type) {
case "text":
newcell.childNodes[0].value = "";
break;
case "checkbox":
newcell.childNodes[0].checked = false;
break;
case "select-one":
newcell.childNodes[0].selectedIndex = 0;
break;
}
}
}
After inserting data through the form, I want to output the table data through php echo. But I can't figure out how to output every row from the dynamic table because right now it just gives me the last row.
In the following fashion I want to output the data:
echo $var_name."<br>";
Right now I have 5 variables for each row in the table, but they only give me the latest row input (logical)