<input type="hidden" id="name" name="name">
<input type="hidden" id="lastName" name="lastName">
for (const [ k, v ] of new URLSearchParams(url.replace(/.*\?/, ''))) {
document.querySelector(`#${k}`).value = v;
}
url
.slice(url.indexOf('?') + 1)
.split('&')
.map(n => n.split('='))
.forEach(n => document.getElementById(n[0]).value = n[1]);
const data = [...url.split('?').pop().matchAll(/([^&]+)=([^&]*)/g)];
for (let i = 0; i < data.length; i++) {
document.querySelector(`[id="${data[i][1]}"]`).value = data[i][2];
}