2 Replies Latest reply on Feb 8, 2018 2:28 AM by Derrick Chiang

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

    Derrick Chiang

      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.