2

When I use this script

<form id="mktoForm_1740"></form>
<script>MktoForms2.loadForm("//app-e.example.com", "517-ITT-285", 1740);</script>

the form will load normally. But the below script didn't load form. I think problem related to javascript.

<script>MktoForms2.loadForm("//app-example.com", "517-ITT-285", 1740, function(form){
    //Add an onSuccess handler
    form.onSuccess(function(values, followUpUrl){
        //get the form's jQuery element and hide it
        form.getFormElem().hide();
        document.getElementById('confirmform').style.visibility = 'visible';
        //return false to prevent the submission handler from taking the lead to the follow up url.
        return false;
    });
    });
</script>
<div id="confirmform" style="visibility:hidden;margin-top: 35px;"><p><strong>Thank you for registering. You will receive a confirmation by email in a minute.</strong></p></div>

How to fix this problem........

2 Answers 2

1

use $(document).ready(function(){});

try this

<script>
    $(document).ready(function() {
        MktoForms2.loadForm("//app-example.com", "517-ITT-285", 1740, function(form) {
            //Add an onSuccess handler
            form.onSuccess(function(values, followUpUrl) {
                //get the form's jQuery element and hide it
                form.getFormElem().hide();
                document.getElementById('confirmform').style.visibility = 'visible';
                //return false to prevent the submission handler from taking the lead to the follow up url.
                return false;
            });
        });
    });
</script>
<div id="confirmform" style="visibility:hidden;margin-top: 35px;">
    <p><strong>Thank you for registering. You will receive a confirmation by email in a minute.</strong></p>
</div>
Sign up to request clarification or add additional context in comments.

1 Comment

I need the js code. Because after submission I want to display the hidden div.
0
<form id="mktoForm_1740"></form>
<script>MktoForms2.loadForm("//app-example.com", "517-ITT-285", 1740, function(form){
    form.onSuccess(function(values, followUpUrl){
        form.getFormElem().hide();
        document.getElementById('confirmform').style.visibility = 'visible';
        return false;
    });
});</script>

Use above code. this will work.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.