Custom JS for forms
I am not fluent in JS, but was trying to create an embed script to put a form on an outside page, while also allowing the CTA to be changed, as well as re-directing the thank you page based on the URL where the form was embedded. Here is my code:
<script src="//go.autoshopsolutions.com/js/forms2/js/forms2.min.js "></script>
<form id="mktoForm_3948"></form>
<script>
MktoForms2.loadForm("//go.autoshopsolutions.com", "180-DGD-014", 3948, function(form){
form.addHiddenFields({ LastFormURL : document.location.href })
});
</script>
<script>
{
const ctaText = "Download Now";
/* -- NO NEED TO TOUCH BELOW HERE -- */
MktoForms2.whenReady(function(readyForm){
const formEl = readyForm.getFormElem()[0],
buttonEl = formEl.querySelector(".mktoButton[type='submit']");
buttonEl.textContent = ctaText;
});
}
</script>I have also setup the Marketo form to redirect based on the new field I created in Marketo called LastFormUrl
It doesn't work though and instead just stays on the page, which is the default action.
Any ideas?
