SOLVED

How to load a different form inside another form object with forms 2.0 api?

Go to solution
John_Wallace
Level 4

How to load a different form inside another form object with forms 2.0 api?

Hi I am trying to use the forms 2.0 api on our website.  I was interested in using two different forms in order to break up the overall length of the form.  I was wondering if it is possible to load another form after one has been submitted.  I just was wondering if anyone has a working code example of this.  This is what I have so far, thanks.  

-John

 <script>
 
                MktoForms2.loadForm("//app-sjp.marketo.com", "466-AGZ-592", 333, function(form) {
                    form.onSuccess(function(callback) {
                        form.getFormElem().hide();
                        MktoForms2.loadForm("//app-sjp.marketo.com", "466-AGZ-592", 334, function(forms) {
                                form.getFormElem().show();
                        });
                    });              
                });
 
                </script>
Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Re: How to load a different form inside another form object with forms 2.0 api?

Hi John,

Please make sure the form tags for each form instance is present in the document. 
 

<script src="//app-sjo.marketo.com/js/forms2/js/forms2.js"></script>
 
<form id="mktoForm_333"></form>
<form id="mktoForm_334"></form>
 
<script>
    MktoForms2.loadForm("//app-sjo.marketo.com", "466-AGZ-592", 333,
            function(firstForm){
                firstForm.onSuccess(function(){
                    MktoForms2.loadForm("//app-sjo.marketo.com", "466-AGZ-592", 334);
                    firstForm.getFormElem().hide();
                    //return false to prevent the submission handler from taking the lead to the follow up url.
                    return false;
                });
            });
</script>

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Re: How to load a different form inside another form object with forms 2.0 api?

Hi John,

Please make sure the form tags for each form instance is present in the document. 
 

<script src="//app-sjo.marketo.com/js/forms2/js/forms2.js"></script>
 
<form id="mktoForm_333"></form>
<form id="mktoForm_334"></form>
 
<script>
    MktoForms2.loadForm("//app-sjo.marketo.com", "466-AGZ-592", 333,
            function(firstForm){
                firstForm.onSuccess(function(){
                    MktoForms2.loadForm("//app-sjo.marketo.com", "466-AGZ-592", 334);
                    firstForm.getFormElem().hide();
                    //return false to prevent the submission handler from taking the lead to the follow up url.
                    return false;
                });
            });
</script>

John_Wallace
Level 4

Re: How to load a different form inside another form object with forms 2.0 api?

Hey thanks for the response Haven