+ 1
how to send data from a form in html to JSON using Javascript?
send data to JSON using Javascript
1 Réponse
+ 2
First respond (addEventListener) to a button click like a submit or send click. Within the callback function of the event listener obtain the values from all form inputs...
e.g document.getElementById("name").value
Next store all obtained value from the DOM in an object.
e.g const user = {name: "", ..... }
finally use use JSON to convert the object into JSON format.
e.g console.log(JSON.stringify(user));
I have shorten lots of details but hope you get the idea.