Answers for "js get formdata values"

4

how to console.log formData

// Display the values
for (var value of formData.values()) {
   console.log(value); 
}
Posted by: Guest on July-09-2020
0

js get data from form

const form = document.querySelector('form');
const data = new FormData(form);
Posted by: Guest on April-14-2021
6

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>
Posted by: Guest on June-07-2020
0

js get form data

document.addEventListener('submit', function (event) {

	event.preventDefault();

	fetch('https://xxx.xxx', {
		method: 'POST',
		body: new FormData(event.target),
	}).then(function (response) {
		if (response.ok) {
			return response.json();
		}
		return Promise.reject(response);
	}).then(function (data) {
		console.log(data);
	})
});
Posted by: Guest on March-26-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language