Checkboxes type to NULL | Community
Skip to main content
New Participant
January 24, 2024
Solved

Checkboxes type to NULL

  • January 24, 2024
  • 2 replies
  • 3308 views

 Can the checkboxes field type can be made to NULL if none of the options is selected for a filed For example: I have four checkboxes for a field in my form and initially one was checked later all were unchecked can the field be made NULL?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

Add a checkbox with the literal string value NULL.

 

Hide it by default:

.mktoForm .mktoCheckboxList input[value="NULL"], .mktoForm .mktoCheckboxList input[value="NULL"] + label { display: none; }

 

If the value is empty on submit, then flip it to NULL.

MktoForms2.whenReady(function(readyForm){ readyForm.onSubmit(function(submittingForm){ const currentValues = submittingForm.getValues(); if(currentValues.MyInterestingField == "") { submittingForm.setValeus({ MyInterestingField : "NULL" }); }); }); });

2 replies

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
January 24, 2024

Add a checkbox with the literal string value NULL.

 

Hide it by default:

.mktoForm .mktoCheckboxList input[value="NULL"], .mktoForm .mktoCheckboxList input[value="NULL"] + label { display: none; }

 

If the value is empty on submit, then flip it to NULL.

MktoForms2.whenReady(function(readyForm){ readyForm.onSubmit(function(submittingForm){ const currentValues = submittingForm.getValues(); if(currentValues.MyInterestingField == "") { submittingForm.setValeus({ MyInterestingField : "NULL" }); }); }); });
New Participant
January 25, 2024

Love this. Another way: if you would rather use OOTB capabilities, you could use a Change Data Value flowstep that triggers on form fill, create a choice that says IF none of the fields contain any of the checkbox values then make the field NULL. 

 

 

 

SanfordWhiteman
New Participant
January 25, 2024

Well, no.

 

The goal is to empty the field if the person didn’t check off any of the visible fields, because otherwise the field will be left with its old value.

 

Your flow choice is saying “if it’s already empty, empty it.” It won’t have any any effect.

Jo_Pitts1
Community Manager
January 24, 2024

@hemanthappachu

I'm confused by this part of your post:


@hemanthappachu wrote:

I have four checkboxes for a field in my form


One checkbox relates to one field.  Can you clarify your question please.  Maybe some screenshots?

SanfordWhiteman
New Participant
January 24, 2024

Presumably meaning the Checkboxes type?