+ 1

how to send data from a form in html to JSON using Javascript?

send data to JSON using Javascript

11th Jun 2017, 1:14 PM
Wahid Arinanto Nugroho
Wahid Arinanto Nugroho - avatar
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.
13th Jun 2017, 11:10 AM
Benneth Yankey
Benneth Yankey - avatar