SOLVED

modifying form html

Go to solution
Anonymous
Not applicable

modifying form html

Is there a way to actually modify the html of the forms that are created?  For example lets say I wanted to add an Id or change the class name or add a new attribute altogether.

Thanks,
 

Dan

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Kenny_Elkington
Marketo Employee

Re: modifying form html

Hey Daniel,

You cannot do this from directly within the form editor, but you can do this with the addition of some custom code.  Since Forms 2 loads asynchronously you'll need to use the whenReady event to make sure that the code executes correctly:

<script>
MktoForms2.whenReady(function(form){
$('#yourId').addClass('myClass myOtherClass'); //add a class
$('#yourId').attr('yourAttribute', 'yourValue'); //add an attribute with a value
});
</script>

Keep in mind that you can only have a single id per element, so overwriting this is not a good id, and can break form functionality.

View solution in original post

3 REPLIES 3
Dory_Viscoglio
Level 10

Re: modifying form html

Hi Dan, I believe that you can do this on the page where your form resides. It isn't done directly in the form.
Kenny_Elkington
Marketo Employee

Re: modifying form html

Hey Daniel,

You cannot do this from directly within the form editor, but you can do this with the addition of some custom code.  Since Forms 2 loads asynchronously you'll need to use the whenReady event to make sure that the code executes correctly:

<script>
MktoForms2.whenReady(function(form){
$('#yourId').addClass('myClass myOtherClass'); //add a class
$('#yourId').attr('yourAttribute', 'yourValue'); //add an attribute with a value
});
</script>

Keep in mind that you can only have a single id per element, so overwriting this is not a good id, and can break form functionality.
Anonymous
Not applicable

Re: modifying form html

Thanks for that!  That worked.

Dan