BudgetingApp/app/static/split_line.js
ydb5755 86b1ccb3de move counter to global
remove inputs from template and move all generation of inputs to js script
2024-10-29 15:25:32 +02:00

27 lines
No EOL
785 B
JavaScript

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');
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.placeholder = column
td.appendChild(ip)
tr.appendChild(td)
})
counter++
lineContainer.appendChild(tr)
}
document.addEventListener('DOMContentLoaded', () => {
addLine()
addLineButton.addEventListener('click', addLine)
})