My form contains the Country selectmenu. When users select United States from that selectmenu, the States selecetmenu appears; when users select a non-US country, the States selectmenu disappears.
The problem is that my form isn't responding to programatically manipulations of the Country selectmenu. When I manually select United States, the State selectmenu appears correctly. But when United States is selected programmatically (for example, by using the following javascript code), the State selectmenu isn't appearing.
document.getElementById('Country').options[1].selected = true;
How do I make my form respond to programatically manipulations of the Country selectmenu?
Solved! Go to Solution.
setValues is a method of an individual Marketo form instance, not a static method of the MktoForms2 object.
So you need to get a handle to the form, e.g.
MktoForms2.getForm(1499).setValues( /* values object */ )
Never use DOM methods on Marketo forms. Use the Forms API setValues() method.
Thanks. How do I set values after my form had been initialized? The example in the Examples page seems to combine initialization and value setting together.
I tried the following code but got an error (Uncaught TypeError: MktoForms2.setValues is not a function):
MktoForms2.setValues({ Country: 'United States' });
setValues is a method of an individual Marketo form instance, not a static method of the MktoForms2 object.
So you need to get a handle to the form, e.g.
MktoForms2.getForm(1499).setValues( /* values object */ )
Thank you very much. I see.