2 Replies Latest reply on Sep 13, 2017 12:14 PM by 281db41d4248c87bc98d7319297df8be9cbeaf70

    Best way to submit user entered javascript variables via Forms 2.0?

      Hello community,


      I have a question to see if I'm approaching my project the best way I can.


      We're creating a 10 question quiz.  The quiz is designed in a way that wouldn't work well with a standard Marketo form (the quiz is a series of connected screens, one question displayed at a time, all on one page), although we'd ultimately like to have user answers submitted to our lead database.


      To achieve this, it seems that the “.addHiddenFields(values)" method using forms 2.0 would work well.


      On the page, users would click buttons (styled div containers) to indicate their answer to a question.  These button clicks would initiate jQuery events that assign each answer to a variable – in this case, the array “answer[]”.


      The email address field would be an HTML input field. Ultimately, I submit like this:






                     "Email": email,

                     "q1": answer[1],

                     "q2": answer[2],

                    "q3": answer[3],

                    "q4": answer[4],

                    "q5": answer[5],

                    "q6": answer[6]




                form.onSuccess(function(callback) {

                return false;








      The code works – but is this a sound solution?  From what I’ve read, the form.submit() method performs all validation, so it’s good from that perspective - but I wanted to make sure there wasn't a better way.