This content has been marked as final.
Show 2 replies
-
Re: How to use variables in the object of setValues() method?
Sanford Whiteman Feb 8, 2018 1:57 AM (in response to Derrick Chiang)So I would like to make the object name and value as variables:
MktoForms2.getForm(1499).setValues({ this.name: this.value });
JavaScript never works this way. It has nothing to with the Marketo JS API in particular.
Dot-property names are (if you want anything close to real-world browser compatibility) constants.
If you want dynamic property names, use bracket notation.
var mktoFields = {}; mktoFields[this.name] = this.value; MktoForms2.getForm(1499).setValues(mktoFields);
-
Re: How to use variables in the object of setValues() method?
Derrick Chiang Feb 8, 2018 2:28 AM (in response to Sanford Whiteman)That works! Thank you very much.
-