2025-02-10 08:07:36 +00:00
|
|
|
function collectEditedData(event) {
|
2025-02-22 20:55:55 +00:00
|
|
|
// Extract headers (attribute names) from the table
|
2025-02-10 08:52:22 +00:00
|
|
|
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 = [];
|
|
|
|
|
2025-02-22 20:55:55 +00:00
|
|
|
// Iterate through rows and collect data
|
2025-02-04 19:49:34 +00:00
|
|
|
rows.forEach(row => {
|
|
|
|
const cells = row.querySelectorAll('td');
|
2025-02-10 08:52:22 +00:00
|
|
|
let asset = {};
|
|
|
|
headers.forEach((attrib, i) => asset[attrib] = cells[i].innerText);
|
|
|
|
assets.push(asset);
|
2025-02-04 19:49:34 +00:00
|
|
|
});
|
|
|
|
|
2025-02-22 20:55:55 +00:00
|
|
|
// Create a hidden input field to store the collected data
|
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
|
|
|
|
2025-02-22 20:55:55 +00:00
|
|
|
// Submit the form
|
2025-02-10 08:52:22 +00:00
|
|
|
event.target.submit();
|
2025-02-10 08:07:36 +00:00
|
|
|
return true;
|
2025-02-22 20:55:55 +00:00
|
|
|
}
|