How to pass <legend> from HTML to TS file?

I’ve figured out how to pass an input form to the TS file:

<p>
        <label for="receiverName">Name</label>
        <input type="text" id="receiverName" name="receiverName">
</p>

But when I try to pass the of a form containing that input, nothing happens.

<legend for="fromLabel" type="legend" id="fromLabel" name="fromLabel">From</legend>

I use the following script to pass the form data, which works wells for inputs.

    <script>
        document.getElementById('generate').onclick = (event) => {

            // Get the form
            let pluginForm = document.querySelector('#pluginForm')

            // Get the field data from the form
            let pluginFormData = new FormData(pluginForm)

            // Create an object and populate it with form data
            let formDataObj = {}

            for (let[key, value] of pluginFormData) {
                formDataObj[key] = value
            }

            parent.postMessage({pluginMessage: {type: 'actionGenerate', formDataObj}}, '*')
        }
    </script>

I suspect there’s something I need to change about the script. Anyone ran into this issue before?

Solved the issue :white_check_mark: