SOLVED

Re: Can someone tell me why this Javascript does not work with a published Forms 2.0 form?

Go to solution
Anonymous
Not applicable

Can someone tell me why this Javascript does not work with a published Forms 2.0 form?

I have tried this in both my template and on the landing page. I get the document ready alert but the second alert returns "undefined". I don't seem to be able to access anything from the DOM with forms 2.0 forms.
Can anyone point me in the right direction to do this?

<script type="text/javascript">// <![CDATA[
jQuery(document).ready(function(){
            alert("document ready called");
          
            alert(jQuery('.mktoForm').attr('height'));
});
// ]]></script>
Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Kenny_Elkington
Marketo Employee

Re: Can someone tell me why this Javascript does not work with a published Forms 2.0 form?

Hey Sharon,

We recommend using a callback from the whenReady function for these kinds of things like so:

<script>
MktoForms2.whenRead( function(form){
alert(jQuery('.mktoForm').attr('height'));
});
</script>

You can find more about the Forms 2 api here: http://developers.marketo.com/documentation/websites/forms-2-0/

View solution in original post

2 REPLIES 2
Kenny_Elkington
Marketo Employee

Re: Can someone tell me why this Javascript does not work with a published Forms 2.0 form?

Hey Sharon,

We recommend using a callback from the whenReady function for these kinds of things like so:

<script>
MktoForms2.whenRead( function(form){
alert(jQuery('.mktoForm').attr('height'));
});
</script>

You can find more about the Forms 2 api here: http://developers.marketo.com/documentation/websites/forms-2-0/
Anonymous
Not applicable

Re: Can someone tell me why this Javascript does not work with a published Forms 2.0 form?

That worked. Thank you!!