flask_crud_app/static/edited_csv.js

25 lines
793 B
JavaScript
Raw Normal View History

2025-02-10 08:07:36 +00:00
function collectEditedData(event) {
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');
assets.push({
assettag: cells[0].innerText,
hostname: cells[1].innerText,
warrantyfrom: cells[2].innerText,
status: cells[3].innerText,
staffnum: cells[4].innerText
});
});
// Add edited data to a hidden input
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(); // Submit the form after attaching data
return true;
2025-02-04 19:49:34 +00:00
}