move counter to global
remove inputs from template and move all generation of inputs to js script
This commit is contained in:
parent
bb7bc37a3e
commit
86b1ccb3de
2 changed files with 5 additions and 10 deletions
|
|
@ -1,25 +1,27 @@
|
|||
const addLineButton = document.getElementById("add-line-button");
|
||||
const lineContainer = document.getElementById('table-body');
|
||||
var counter = 1;
|
||||
|
||||
function addLine(){
|
||||
const columns = ['Amount', 'Vendor', 'Confirmation Code', 'Note'];
|
||||
var tr = document.createElement('tr');
|
||||
var counter = 2;
|
||||
columns.forEach(column => {
|
||||
var td = document.createElement('td');
|
||||
var ip = document.createElement('input');
|
||||
ip.type = 'text'
|
||||
ip.classList = 'form-control'
|
||||
ip.name = `${column}-${counter++}`
|
||||
ip.name = `${column}-${counter}`
|
||||
ip.placeholder = column
|
||||
td.appendChild(ip)
|
||||
tr.appendChild(td)
|
||||
})
|
||||
counter++
|
||||
lineContainer.appendChild(tr)
|
||||
|
||||
}
|
||||
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
addLine()
|
||||
addLineButton.addEventListener('click', addLine)
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue