How to load a different form inside another form object with forms 2.0 api? | Community
Skip to main content
New Participant
August 8, 2014
Solved

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

  • August 8, 2014
  • 2 replies
  • 1437 views
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>
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by

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>

2 replies

New Participant
August 11, 2014
Hey thanks for the response Haven
Accepted solution
August 11, 2014

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>