SOLVED

Re: Show/hide form fields based on lead info

Go to solution
Anne_Sample1
Level 2

Show/hide form fields based on lead info

We are trying to set up a subscription management center, so that leads can subscribe to only certain types of emails if they so desire. However, some of our subscription categories are not available to all of our leads, so we want to be able to completely hide the subscribe/unsubscribe option if you are not already subscribed. For these categories, leads should be able to unsubscribe if we have marked them as subscribed, but should not see the category as an option if otherwise.

What's the best way to handle this?

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Show/hide form fields based on lead info

OK. While prefilled fields + Visibility Rules are good for dependencies between fields (if (A equals "Yes") show B) they aren't so good for self-dependencies (if (A equals "Yes") show A).  For more complex visibility I would lean toward CSS.  Add a class to the form that indicates their eligibility:

MktoForms2.whenReady(function(form){

  form.className += "eligGroup1-{{lead.eligGroup1}} eligGroup2-{{lead.eligGroup2}}";

});

so you end up with <FORM class="eligGroup1-yes eligGroup2-no">.  Then hide parts of the form based on that.

I do wonder if you're covering all your cases, though.  If you're using a single field to determine both eligibility to subscribe to A and subscription to A, what do you do if someone unsubscribes but should later be allowed to resubscribe?

View solution in original post

5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

Re: Show/hide form fields based on lead info

Is this page a Marketo-hosted LP?

Josh_Hill13
Level 10 - Champion Alumni

Re: Show/hide form fields based on lead info

Most likely some javacsript and jquery.

I never really get this though - why NOT let people see your subscription options? How can they subscribe if you hide it?

Anne_Sample1
Level 2

Re: Show/hide form fields based on lead info

Hi Josh -

In this case it is because there are some products that we are only allowed to sell to a pre-approved list of companies. At some point we'd love to expand to sell to more people, but since we are the wholesaler it isn't really our call and we have to follow the seller's rules.

Sanford, this is a Marketo-hosted LP.

SanfordWhiteman
Level 10 - Community Moderator

Re: Show/hide form fields based on lead info

OK. While prefilled fields + Visibility Rules are good for dependencies between fields (if (A equals "Yes") show B) they aren't so good for self-dependencies (if (A equals "Yes") show A).  For more complex visibility I would lean toward CSS.  Add a class to the form that indicates their eligibility:

MktoForms2.whenReady(function(form){

  form.className += "eligGroup1-{{lead.eligGroup1}} eligGroup2-{{lead.eligGroup2}}";

});

so you end up with <FORM class="eligGroup1-yes eligGroup2-no">.  Then hide parts of the form based on that.

I do wonder if you're covering all your cases, though.  If you're using a single field to determine both eligibility to subscribe to A and subscription to A, what do you do if someone unsubscribes but should later be allowed to resubscribe?

Anne_Sample1
Level 2

Re: Show/hide form fields based on lead info

That's a good point, Sanford! While most of our leads who have the conditional category are also only allowed to subscribe to that one category (for now), it would be a good idea to future-proof this.

Having two fields for each category - one boolean for "is eligible," and one for "is subscribed," would simultaneously solve the re-subscribing issue and make it possible to use prefilled forms and visibility rules instead of custom CSS. Much easier!