AnsweredAssumed Answered

How to use variables in the object of setValues() method?

Question asked by 652ae51ce3bf87fae3d9dbbb4c8ebf4a653f0cc6 on Feb 8, 2018
Latest reply on Feb 8, 2018 by 652ae51ce3bf87fae3d9dbbb4c8ebf4a653f0cc6

I have several selectmenues whose values will be changed by a jQuery function. Since Marketo form does not respond to that kind of DOM method. I have to write an additional line of code by using Marketo's Forms API setValues() method in that jQuery function to let Marketo form know what happened.

 

Normally, for a single selectmenu, the code would look like:

MktoForms2.getForm(1499).setValues({ Country: 'United States' });

 

But there are other selectmenues, not just Country. So I would like to make the object name and value as variables:

MktoForms2.getForm(1499).setValues({ this.name: this.value });

 

this in the above code refers to <select> element which is being changed. But the above code is yielding an error (Uncaught SyntaxError: Unexpected token .)

 

Any advice would be much appreciated. Thanks.

Outcomes