SOLVED

Conditionally fill empty form fields with default values

Go to solution
Jo_Pitts1
Level 10 - Community Advisor

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

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Conditionally fill empty form fields with default values

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.

View solution in original post

2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

Re: Conditionally fill empty form fields with default values

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
Level 10 - Community Advisor

Re: Conditionally pre-fill form fields

Sanford,

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

As always, cheers for validating my slightly meandering thinking 🙂