javascript - How can I get all a form's values that would be submitted without submitting - Stack Overflow

PHOTO EMBED

Thu Oct 29 2020 12:17:28 GMT+0000 (Coordinated Universal Time)

Saved by @Bujhm

var params = '';
for( var i=0; i<document.FormName.elements.length; i++ )
{
   var fieldName = document.FormName.elements[i].name;
   var fieldValue = document.FormName.elements[i].value;

   // use the fields, put them in a array, etc.

   // or, add them to a key-value pair strings, 
   // as in regular POST

   params += fieldName + '=' + fieldValue + '&';
}

// send the 'params' variable to web service, GET request, ...
content_copyCOPY

https://stackoverflow.com/questions/588263/how-can-i-get-all-a-forms-values-that-would-be-submitted-without-submitting