Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

console form elememts as json object

function handleSubmit(event) {
    event.preventDefault();

    const data = new FormData(event.target);

+   const value = Object.fromEntries(data.entries());

    console.log({ value });
  }

  const form = document.querySelector('form');
  form.addEventListener('submit', handleSubmit);
Source by www.learnwithjason.dev #
 
PREVIOUS NEXT
Tagged: #console #form #elememts #json #object
ADD COMMENT
Topic
Name
7+5 =