Skip to main content
Jo_Pitts1
Community Advisor
Community Advisor
May 10, 2021 10:58 PM UTC
Solved

Conditionally fill empty form fields with default values

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.
SanfordWhiteman
SanfordWhitemanAccepted solution
User Group Leader
May 10, 2021 11:30 PM UTC

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.

2 replies

SanfordWhiteman
User Group Leader
SanfordWhitemanUser Group LeaderAccepted solution
User Group Leader
May 10, 2021 11:30 PM UTC

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.

Translate
Jo_Pitts1
Community Advisor
Jo_Pitts1Community AdvisorAuthor
Community Advisor
May 11, 2021 12:23 AM UTC

Sanford,

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

As always, cheers for validating my slightly meandering thinking 🙂

Translate