SOLVED

Re: Checkboxes type to NULL

Go to solution
Appachu
Level 1

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

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

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

Hi Sanford,

 

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

Jo_Pitts1
Level 10 - Community Advisor

@Appachu ,

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

Regards

Jo

jsiebert
Level 5

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

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
Level 10 - Community Advisor

@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

Presumably meaning the Checkboxes type?