There are some circumstances where you may want to auto-submit a form when a user hits a certain page. If someone has completed a form on the same device before, their information will be automatically filled in. This can be helpful for tracking or other purposes.
Add your form to the page like the one below.
Save Draft, Preview Draft.
Hit F12 for dev mode and click the button top left of dev mode.
Hover your cursor over the button of the form, and a single click.
A large sidebar of code will become visible, and a section will be highlighted.
It will start with <button
To copy the JS path, simply right-click and choose “Copy”.
Jump back into the website builder, page setting, custom code, and body end
document.querySelector("#ebhm5a > button")
Please note, yours will not say #ebhm5a, yours will be 5 different letters/numbers
Click Save at the bottom of the page.
Copy the code below (including the <script> </script> tags)
<script>
const butt = document.querySelector("#ebhm5a > button")
butt.setAttribute('id', 'butt');
setTimeout("CallButton()",1000)
function CallButton(){
document.getElementById("butt").click();
}
</script>
You need to put it in Page Setting > Custom Code > Body End
Put it underneath what you just copied.
This code automatically clicks the submit button on the form 1 second after the page loads. All we need to do is change the part highlighted in red.
Copy the entire top line and put it into the script like as shown in the image above.
Yours should look identical except the #ebhm5a will be different.
Click Save.
Congratulations, your form will now auto-submit itself after 1 second.
If you want to make the form invisible, simply copy the code below beneath what you already have.
<style>
.crm-co-form {
visibility: hidden !important;
}
</style>
Publish.