Same form but only split completion count if certain field is filled. | Community
Skip to main content
Callum_Pirie
New Participant
January 8, 2019
Solved

Same form but only split completion count if certain field is filled.

  • January 8, 2019
  • 1 reply
  • 1701 views

Hi there,

I hope this makes sense. I have a form on our website which is below

is there a way to run the same form above but only count the completion as a contact request if the query box is populated at all?

Here are the hidden fields we have:

and for Account Source its B2B Partnership Enquiry so we know someone used the Enquiry form on the website however the other form we have with similar fields are just called 'Brochure Download'

If I was to have Account Source: B2B Partnership Enquiry and Person Source: B2B Partnership Enquiry and then below that Account Source II: Brochure Download and Person Source II: Brochure Download could I then jump in the if statement area and make this happen?

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

Your phrasing is unclear: what do you mean by "jump in the if statement area"?

If you mean the Visibility Rules list, then no, you can't set a field's value using VRs.

Do you want to only populate a certain field if another field is non-empty, you must use JS.

MktoForms2.whenReady(function(form){
  form.onSubmit(function(form){
    var currentValues = form.getValues();

    if (currentValues.someVisibleTextField != "") {

      form.addHiddenFields({

        isSomeKindOfInterestingRequest : "Yep, it's interesting"

      });

    }

  });

});

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
January 8, 2019

Your phrasing is unclear: what do you mean by "jump in the if statement area"?

If you mean the Visibility Rules list, then no, you can't set a field's value using VRs.

Do you want to only populate a certain field if another field is non-empty, you must use JS.

MktoForms2.whenReady(function(form){
  form.onSubmit(function(form){
    var currentValues = form.getValues();

    if (currentValues.someVisibleTextField != "") {

      form.addHiddenFields({

        isSomeKindOfInterestingRequest : "Yep, it's interesting"

      });

    }

  });

});

Callum_Pirie
New Participant
January 8, 2019

Hi Sanford,


Thanks for this -