how to get form data using javascript w3schools code example

Example 1: javascript get form data

<html>
    <form id="myForm">
        <input type="text" name="email" value="[email protected]">
    </form>
    <p id='text'></p>

    <script>
        window.setInterval(()=>{
            var myForm = document.getElementById('myForm');
            var text = document.getElementById('text');

            text.innerText = myForm.elements['email'].value;
        }, 1);
    </script>
</html>

Example 2: javascript form data

var formData = new FormData();
fromData.append('name','value');

Example 3: js retrieve form data

var nameValue = document.getElementById("uniqueID").value;

Tags:

Html Example