Дoпустим есть
<div id='form'></div>
и в нем надо сформировать эту форму
let ediv = document.getElementById('form')
ediv.innerHTML = `<form name="test" method="post" action="https://test.com/test.php" accept-charset="UTF-8">
<input type="hidden" name="Id1" value="${first}" />
<input type="hidden" name="Id2" value="${second}" />
<input type="hidden" name="id3" value="${third}" />
<input type="hidden" name="id4" value="${fouth}" />
<input type="submit" value="${fifth}">
</form>`