I have a table created that looks like this:
<form role="form" method="post" action="" enctype="multipart/form-data">
<table class="table table-striped" id='billables'>
<input type='hidden' name='products' id='products' value='0'>
<thead>
<tr>
<th>Description</th>
<th>Quantity (#)</th>
<th>Rate ($)</th>
<th>Amount ($)</th>
</tr>
</thead>
<tbody >
//The ROW gets inserted properly here, and each row gets
assigned a "input variable" properly
</tbody>
</table>
</form>
and I am using a javascript function that when a button is clicked will add a new row to the table with input fields.
function addRow() {
var products = document.getElementById("products").value;
products = parseFloat(products)
products = products + 1;
document.getElementById("products").value = products;
var table = document.getElementById("billables");
var row = table.insertRow(products);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
var cell4 = row.insertCell(3);
cell1.innerHTML = '<input class="form-control" id="'+products+'desc" type="text" name="'+products+'desc" required placeholder="Item Desc..." >';
cell2.innerHTML = "<input class='form-control' id='"+products+"quant' type='number' name='"+products+"quant' required placeholder='Quantity...' >";
cell3.innerHTML = "<input class='form-control' id='"+products+"rate' type='number' name='"+products+"rate' required step='0.01' placeholder='Ex: 23.99' onkeyup='calc()'>";
cell4.innerHTML = "<input class='form-control' id='"+products+"amm' type='number' name='"+products+"amm' readonly >";
}
The "name" and "id" field get dynamically named based on how many rows exist in the table.
IE: 1desc for one row. 1desc,2desc for two rows etc...
The table populates properly, creates the new row, adds a input field for each cell and according to the google debugger/inspect the input fields are named properly.
My issue is that when the form is submitted that values of those elements generated using the innerHTML function do not post properly. Though all the other variables within the form are posted properly.
Any ideas?
edited for clarification - the missing ' was lost when making the post. and the form tag was place much earlier in the code added it to show what it looks like.
Edit:
Pic displaying what the table looks like before the new row is added
Displaying what the table looks like after the new row is added
Google dev tools indicating what the input variable looks like once generated (all correct)
formtag in your HTML?insertCellfunction do?HTMLTableRowElement.insertCell.