function collectEditedData(event) {
    // Prevent default form submission
    event.preventDefault();

    // Extract headers (attribute names) from the table
    const headers = [...document.querySelectorAll('.table-valid-entries thead th')].map(th => th.dataset.attrib);
    const rows = document.querySelectorAll('.table-valid-entries tbody tr');
    const assets = [];

    // Iterate through rows and collect data
    rows.forEach(row => {
        const cells = row.querySelectorAll('td');
        if (cells.length !== headers.length) {
            alert("Mismatch between the number of cells and headers. Please check the table.");
            return false;
        }

        let asset = {};
        headers.forEach((attrib, i) => {
            if (cells[i]) {
                asset[attrib] = cells[i].innerText.trim();
            } else {
                alert(`Missing data for attribute: ${attrib}`);
                return false;
            }
        });
        assets.push(asset);
    });

    // Create a hidden input field to store the collected data
    const input = document.createElement('input');
    input.type = 'hidden';
    input.name = 'assets';
    input.value = JSON.stringify(assets);
    event.currentTarget.appendChild(input);

    // Submit the form
    event.currentTarget.submit();
    return true;
}