0👍
You could use something like element.querySelectorAll('input, select, textarea')
or document.forms['form_name'].getElementsByTagName('input');
to capture all the form elements. You could then iterate though them to find the values and construct a JSON object (or whatever format you need the data in).
Source:stackexchange.com