SOLVED

Checkboxes type to NULL

Go to solution
Appachu
Level 1

Checkboxes type to NULL

 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?

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Checkboxes type to NULL

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"
      });
    });
  });
});

View solution in original post

7 REPLIES 7
Jo_Pitts1
Level 10 - Community Advisor

Re: Checkboxes type to NULL

@Appachu

I'm confused by this part of your post:


@Appachu 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
Level 10 - Community Moderator

Re: Checkboxes type to NULL

Presumably meaning the Checkboxes type?

SanfordWhiteman
Level 10 - Community Moderator

Re: Checkboxes type to NULL

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"
      });
    });
  });
});
jsiebert
Level 5

Re: Checkboxes type to NULL

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. 

 

jsiebert_1-1706196682443.png

 

 

Jack Siebert
SanfordWhiteman
Level 10 - Community Moderator

Re: Checkboxes type to NULL

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.

Appachu
Level 1

Re: Checkboxes type to NULL

Hi Sanford,

 

I had my developers implement this script but it doesn't appear to work

Jo_Pitts1
Level 10 - Community Advisor

Re: Checkboxes type to NULL

@Appachu ,

can we get a URL to your page please.  Otherwise we're shooting blind.

Regards

Jo