SOLVED

Multiselect checkboxes in a form

Go to solution
Milena_Volkova
Level 3

Multiselect checkboxes in a form

Hi everybody. I need to create a form where people can sign up for training events and select up to 16 different events/days/times at a time. Upon form submission, Marketo should send an email alert to the internal team listing the options selected. 

I can create 16 checkbox (boolean) fields and 16 string fields. The string fields will contain the day/time information that corresponds to each T/F checkbox. If checkbox 1 = TRUE, then I change the data value in the corresponding string field 1 so I can use that text in the email alert, etc. 

I'll recycle these fields as the dates pass and new dates are added to the schedule. 

In the email alert body, there will be gaps because not all dates will be selected. 

Is there a more scalable and elegant solution to this that's still easy to implement? 

This is what it looks like in the email setup: 

Milena_Volkova_0-1719351896654.png

and here is this text in the actual email when option 1 and 3 are selected; the white space is due to option 2 not having been selected in the form: 

Milena_Volkova_3-1719352931582.png

 

Another problem is that there is too much space between the lines in the form (whether or not I use a fieldset or place these fields separately without a set). Where there are 16 of them, it'll be really long and ugly. Maybe it's possible to make this list look more compact in CSS: 

Milena_Volkova_2-1719352130808.png

Any advice would be appreciated.

 

 

3 ACCEPTED SOLUTIONS

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Multiselect checkboxes in a form

That setup with Booleans and Strings is almost certainly not the way Iā€™d do it.

 

But if you must do it that way, you can use a Velocity token to output only the non-empty fields.

#set( $fields = [
  "Field_Apple",
  "Field_Orange",
  "Field_Pear",
  "Field_Banana"
] )
#foreach( $field in $fields )
  #if( !$lead[$field].isEmpty() )
    ${lead[$field]}<br>
  #end
#end

 

View solution in original post

SanfordWhiteman
Level 10 - Community Moderator

Re: Multiselect checkboxes in a form

Yes, you only need a single Textarea field and then 16 different checkboxes on the form (using the Checkboxes type in Form Editor).

 

Each box corresponds to a separate sub-value. All sub-values are automatically concatenated by Marketo, with a semicolon as the delimiter.

View solution in original post

SanfordWhiteman
Level 10 - Community Moderator

Re: Multiselect checkboxes in a form

Weā€™re talking about the single delimited string, right? You can split it on the semicolon, then re-join it with an HTML <br>.

 

#set( $subValues = $lead.value.split("\s*;\s*") )
#set( $subValuesWithBreaks = $display.list($subValues,"<br>") )
${subValuesWithBreaks}

 

 

View solution in original post

6 REPLIES 6
SanfordWhiteman
Level 10 - Community Moderator

Re: Multiselect checkboxes in a form

That setup with Booleans and Strings is almost certainly not the way Iā€™d do it.

 

But if you must do it that way, you can use a Velocity token to output only the non-empty fields.

#set( $fields = [
  "Field_Apple",
  "Field_Orange",
  "Field_Pear",
  "Field_Banana"
] )
#foreach( $field in $fields )
  #if( !$lead[$field].isEmpty() )
    ${lead[$field]}<br>
  #end
#end

 

Milena_Volkova
Level 3

Re: Multiselect checkboxes in a form

Thank you, Sanford! Is there a better approach than 32 checkbox + string fields? 

SanfordWhiteman
Level 10 - Community Moderator

Re: Multiselect checkboxes in a form

Yes, you only need a single Textarea field and then 16 different checkboxes on the form (using the Checkboxes type in Form Editor).

 

Each box corresponds to a separate sub-value. All sub-values are automatically concatenated by Marketo, with a semicolon as the delimiter.

Milena_Volkova
Level 3

Re: Multiselect checkboxes in a form

Thank you, Sanford! Is there any way to separate the entries with a break rather than a ';', to make it more readable in the email? I tried <br> between the entries and it did not work. It's not a big deal since I am using it in an internal alert but still would be great to make it more user-friendly. Thank you!

SanfordWhiteman
Level 10 - Community Moderator

Re: Multiselect checkboxes in a form

Weā€™re talking about the single delimited string, right? You can split it on the semicolon, then re-join it with an HTML <br>.

 

#set( $subValues = $lead.value.split("\s*;\s*") )
#set( $subValuesWithBreaks = $display.list($subValues,"<br>") )
${subValuesWithBreaks}

 

 

Milena_Volkova
Level 3

Re: Multiselect checkboxes in a form

Thank you, Sanford!