Auto Submit Marketo Form on Page Load
I have a use case where I want a marketo form to pre-populate fields based on url parameters and then automatically be submitted on page load without any user clicks. I would have thought the code below would work, but it doesn't. Instead, the code makes the page reload over and over again. If it matters, the page is a marketo landing page on a marketo server.
Anyone ever tackle this use case before? Any ideas why the code below doesn't work?
<body>
<div class="mktoContent">
<script src="//app-sj11.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_59"></form>
<script>MktoForms2.loadForm("//app-sj11.marketo.com", "558-YIS-558", 59);</script>
</div>
<script type="text/javascript">
function formAutoSubmit () {
var frm = document.getElementById("mktoForm_59");
frm.submit();
}
window.onload = formAutoSubmit;
</script>
</body>