Hello I'm trying to follow this Add/Delete table rows dynamically using JavaScript
My goal is to scan/enter in barcodes that will make an HTML table. The "user", the "station" will be a variable. The "container" will be entered in once and saved. The only changing item will be scan which is the new row. I've gotten it to add the row but I can't add the variables into their respective columns. Any guidance on this would be great!
Here is my HTML FORM
<form id="trackForm"
autocomplete='off'>
<div class="row">
<div class="col col-lg">
<div id="s1group" class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text">
<b>CONTAINER: </b>
</div>
</div>
<input id="container" class="form-control"
type="text"
placeholder="Scan container."
onpropertychange="checkScanInput();">
</input>
<div class="invalid-feedback">
This field cannot be empty!
</div>
</div>
<div id="s2group" class="input-group">
<div class="input-group-prepend">
<div id="s2label" class="input-group-text font-weight-bold">
SCAN:
</div>
</div>
<input id="scan" class="form-control"
type="text"
placeholder="Scan entry or code."
onpropertychange="checkScanInput();">
</input>
<div class="invalid-feedback">
This field cannot be empty!
</div>
</div>
</div>
</div>
<div class="col-sm-2">
<button id="trackSubmit" class="btn btn-dark font-weight-bold"
type="submit"
style="background-color: #005997; display:none;">
</button>
</div>
</form>
This is the table:
<table id="resultTable" class="table display compact">
<thead>
<tr>
<th>User</th>
<th>Station</th>
<th>Scan</th>
<th>Container</th>
<th>Date/Time</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
Below is the Javascript
var thisStation = stationList[ssv][1];
var sessionUser = document.getElementById('userDisplay').textContent;
var table = document.getElementById("resultTable");
var rowCount = table.rows.length;
var colCount = table.rows[0].cells.length;
var row = table.insertRow(rowCount);
for(var i = 0; i < colCount; i++) {
var newcell = row.insertCell(i);
newcell.innerHTML = table.rows[0].cells[i].innerHTML;
}
row = table.insertRow(table.rows.length);
for(var i = 0; i < colCount; i++) {
var newcell = row.insertCell(i);
if(i == (colCount - 1)) {
newcell.innerHTML = "<INPUT type=\"button\" value=\"Delete Row\" onclick=\"removeRow(this)\"/>";
} else {
newcell.innerHTML = table.rows[3].cells[i].innerHTML;
}
}