Iterate over all your params and retrieve the key and value:
function testParams() {
// Demo hardcoded string, you use window.location.search
const params = new URLSearchParams("testp1=123&testp2=2541");
[...params].forEach(([key, val]) => document.getElementById(key).value = val);
}
window.addEventListener("load", testParams);
<input type="text" name="testp1" id="testp1" />
<input type="text" name="testp2" id="testp2" />
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…