flask_crud_app/static/edited_csv.js

22 lines
707 B
JavaScript
Raw Normal View History

2025-02-10 08:07:36 +00:00
function collectEditedData(event) {
const headers = [...document.querySelectorAll('.table-new-assets thead th')].map(th => th.dataset.attrib);
2025-02-10 08:07:36 +00:00
const rows = document.querySelectorAll('.table-new-assets tbody tr');
2025-02-04 19:49:34 +00:00
const assets = [];
rows.forEach(row => {
const cells = row.querySelectorAll('td');
let asset = {};
headers.forEach((attrib, i) => asset[attrib] = cells[i].innerText);
assets.push(asset);
2025-02-04 19:49:34 +00:00
});
const input = document.createElement('input');
input.type = 'hidden';
input.name = 'assets';
input.value = JSON.stringify(assets);
document.querySelector('form').appendChild(input);
2025-02-10 08:07:36 +00:00
event.target.submit();
2025-02-10 08:07:36 +00:00
return true;
}