Conditionally fill empty form fields with default values | Community
Skip to main content
Jo_Pitts1
Community Manager
May 10, 2021
Solved

Conditionally fill empty form fields with default values

  • May 10, 2021
  • 1 reply
  • 1877 views

Good morning all.

I have an interesting situation where I want to conditionally pre-fill some hidden form fields IF they are blank for the record.

I know I can do this pretty easily a couple of ways:

  1. By always populating a temp field and then in Marketo once the form is submitted testing to see if the main field is empty, and if so, push the temp value into the main field.
  2. In Javascript.  This doesn't work so well across devices however as you might not always get a pre-fill.

Both of these feel slightly like 'work arounds' and I'm feeling option 1. is the most stable and safe.

 

Am I missing an obvious and easy approach here?

 

Cheers

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

Do you mean "pre-fill" or simply "fill"?

 

It seems like you mean "if the field is not populated, then set it to a constant value on form submit" which you can only do in a Marketo flow, because even if you use my cross-domain pre-fill JS that still only applies if the person clicks a Marketo email or has an existing associated Munchkin session. It wouldn't work if they had a new session, starting as anonymous, and then filled out the form.

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
May 10, 2021

Do you mean "pre-fill" or simply "fill"?

 

It seems like you mean "if the field is not populated, then set it to a constant value on form submit" which you can only do in a Marketo flow, because even if you use my cross-domain pre-fill JS that still only applies if the person clicks a Marketo email or has an existing associated Munchkin session. It wouldn't work if they had a new session, starting as anonymous, and then filled out the form.

Jo_Pitts1
Jo_Pitts1Author
Community Manager
May 11, 2021

Sanford,

that was where I think I'd gotten myself to as well 🙂

As always, cheers for validating my slightly meandering thinking 🙂