SOLVED

Marketo Form - Uncheck other checkboxes when 'Unsubscribe from all' box is checked

Go to solution
AndrewS
Level 1

Marketo Form - Uncheck other checkboxes when 'Unsubscribe from all' box is checked

Hello,

 

I've been trying to find some javascript on these forums that will work but have had no luck. Thought I would reach out here in the hopes that somebody can help me out.

 

Basically the form is going to be used for Subscription Preferences - 8 checkboxes in total.

 

The last checkbox is 'Unsubscribe from all'  -  Once checked, I need this checkbox to un-check any other checkboxes that have been checked by the user.

 

Here is the landing page I'm using the test the form: https://page.elmosoftware.com.au/update_subscription-Centre.html

 

If anybody can help point me in the right direction that would be greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Form - Uncheck other checkboxes when 'Unsubscribe from all' box is checked

MktoForms2 :: Select All Checkbox 

 

Set the Stored Value to * (an asterisk) for whatever field you want to be Select/Unselect All.

 

If you want to invert the logic, so the box acts as an Unselect All when it's checked, use -* as the Stored Value.

 

5e975d18806090003884aa06_selectall_formed.png

View solution in original post

13 REPLIES 13
SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Form - Uncheck other checkboxes when 'Unsubscribe from all' box is checked

MktoForms2 :: Select All Checkbox 

 

Set the Stored Value to * (an asterisk) for whatever field you want to be Select/Unselect All.

 

If you want to invert the logic, so the box acts as an Unselect All when it's checked, use -* as the Stored Value.

 

5e975d18806090003884aa06_selectall_formed.png

View solution in original post

AndrewS
Level 1

Re: Marketo Form - Uncheck other checkboxes when 'Unsubscribe from all' box is checked

Hi Sanford

 

Thank you for replying so quickly.

 

Just spoke with our marketing team to clarify the functionality.

 

When a user goes to the page, all boxes will be de-selected  -  they can then choose what they want to subscribe to.

 

If they then click on the 'Unsubscribe from all' checkbox  -  this should only de-select any checkboxes they have previously clicked on.

 

So basically it only needs to behave as a "de-select all other checkboxes" function and never as a "select all" function.

 

Is there a dumbed down version of the script that can achieve this?

 

Thanks again

SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Form - Uncheck other checkboxes when 'Unsubscribe from all' box is checked

Nothing needs to be dumbed down in the code, it uses whatever config you have in Form Editor.

 

So if you only use the -* that's a "positive Unselect All". When it's checked, other boxes are forcibly unchecked.

SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Form - Uncheck other checkboxes when 'Unsubscribe from all' box is checked

Let me fix one thing in the code, though, hold on... that's an older Pen and need to recreate the form.

SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Form - Uncheck other checkboxes when 'Unsubscribe from all' box is checked

OK, republished now.

 

Like I said, you can use whatever features you want. * or -* or both. In the demo, one set of Checkboxes has a * Select All, the other has a -* Unselect All.

 

5e975d18806090003884aa06_selectall_formed_pos.png

 

5e975d18806090003884aa06_selectall_formed_neg.png

AndrewS
Level 1

Re: Marketo Form - Uncheck other checkboxes when 'Unsubscribe from all' box is checked

You're a legend mate!

 

I'll work on it again tomorrow and update the thread once I get it working.

 

Thanks again!

Jessica_Hendrix
Level 1

Re: Marketo Form - Uncheck other checkboxes when 'Unsubscribe from all' box is checked

Hey Sanford, 

 

I'm working with Andrew to get this set up and our form isn't showing the same layout as your screen shot below. Where are you editing the stored value?

 

Here is a screenshot of our form for reference: 

Jessica_Hendrix_0-1588222797483.png

Is there somewhere else in Marketo we should be updating the stored values? I know with picklist values you can edit the API for mapping in advanced settings but since this is a boolean field I'm not seeing an option for a stored value. 

SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Form - Uncheck other checkboxes when 'Unsubscribe from all' box is checked

Hmm, if you don't use a checkbox set (Checkboxes type) then there isn't a relationship between the fields. (Neither visually/in the DOM, nor under the hood.)

 

My screenshots are from a Checkboxes field.

 

It is possible to wire up individual Checkbox (no -es) field together, to create a sort of pseudo-grouping.  But that isn't the way I would do it. Rather, I'd have one visible Checkboxes field that splits its values into multiple hidden, Boolean fields when submitting.

SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Form - Uncheck other checkboxes when 'Unsubscribe from all' box is checked

... and translating the single Checkboxes field to multiple Checkbox fields (mapped to Booleans in Marketo) is done using this code:

 

MktoForms2 :: Checkboxes to multiple hidden Checkbox

 

If you have a Checkboxes group you want to turn into multiple underlying fields, you need to mark up the <label> element like so:

 

2020-04-30 03_05_13-Lab #1208 - Checkboxes and solo Checkbox Select All.png

Other than that the Checkboxes field is set up like any other one:

 

2020-04-30 03_06_10-Lab #1208 - Checkboxes and solo Checkbox Select All.png

 

Note: you do need a single Marketo field backing the Checkboxes field (Firm Status in the example above). It can be a disposable/temporary field, as it's only important for managing the look-and-feel of the form.

 

Then, on submission (right before the form is posted) the code finds all the Stored Values that are checked and for each one, adds a hidden field with the value "yes" (as Booleans expect). Unchecked fields turn into hidden fields set to "no."

 

So if Firm Status has "Fuchsia" and "Gold Checked" on submission, then new fields are created: Fuchsia="yes", Gold="yes", "Turquoise"="no".

 

So you get the best of both worlds: the Checkboxes field type, and the underlying Booleans.

 

This code is separate from the Select All code, though they complement each other well.