We want to set various inputs to the values contained in a str inputValueStr obtained like so:
const form = document.querySelector('#theForm');
var object = Object.values(form).reduce((obj, field) => { obj[field.name] = field.value; return obj }, {});
delete object[""];
const inputValuesStr = new URLSearchParams(object).toString()
The string looks like "foo=&bar=123&baz=examplestr&whatever=". What's a good way to set the #theForm's inputs to the values from the string (ie. make inputs of bar = 123, baz = "examplestr", and other inputs null)?
We're unsure if we're missing something as we don't know what to search for so apologies if this is a stupid question. If so please feel free to redirect us to another thread.