Form submission based on chosen value | Community
Skip to main content
Level 3
April 24, 2018
Question

Form submission based on chosen value

  • April 24, 2018
  • 1 reply
  • 1657 views

Hello everyone,

I was wondering if anyone has had experience with the following scenario:

  • Have one Marketo landing page
  • Have two forms (Form A and Form B) from two different Marketo instances in the background of the landing page
  • Have Form A submit if value of Country equals specific list of values, or have Form B submit as default

I was using this thread as a reference: Make a Marketo Form Submission in the background for submissions in the background. I know that you can use JS to validate field values, and so I am hoping there is a combination of techniques that I can string together and make a coherent request to our developer.

Thanks in advanced!

Danny T.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

SanfordWhiteman
Level 10
April 25, 2018

It sounds like you want to have Form A be a visible form, then short-circuit Form A in an onSubmit listener stage and switch to a hidden Form B post instead.

On a purely functional level this is done by setting form.submittable(false) in onSubmit, then running the hidden form submit as outlined in the blog post. Note this will not, on its own, hide Form A. You'll also have to restyle it so it's not visible, to simulate it having been submitted.

You can pass one form's values object to the other easily, as long as you omit the instance-specific values.

var formAValues = formA.getValues();

["formid","munchkinId"].forEach(function(instanceSpecificField){

  delete formAValues[formSpecificField];

});

// later

formB.setValues(formAValues);