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