Setting Yes/No in Landing Page form to a default Yes or No

In the new Landing Page builder, how can I set Yes/No options in a form to default to either yes or no? Using custom fields.

@Wayne_Manning, could you please clarify how you are wishing to determine whether the value should be marked as ‘Yes’ or ‘No’?

Are you trying to determine the default value for a ‘Yes/No’ custom field using the value of another custom field on the landing page form or hoping to use custom field values stored on the contact record completing the form, or something else?

Timothy, I would like for the contact record to be automatically populated with “Yes” from the Yes/No field when the custom code is activated. The client can then change it to “No” if desired… on an Email Preferences page, for example.

Since posting the question, I have changed the field type to “Dropdown” and listed the options as Yes and No, with Yes the first one and making that the default. This will allow the kinds of searches I want, but just a bit less elegant in presentation.

@Wayne_Manning,

My understanding is you wish to set a custom ‘Yes/No’ field to ‘Yes’ when a form is submitted and that you only wish to have this field’s value change at some point down the road on something like an email preferences page.

If I am understanding this correctly, one option may be to use the ‘Set Field Value’ within Keap’s campaign builder to set the value upon form submission:

2021-06-07_09-50-36

2021-06-07_09-51-28


If you only wish to update the custom field to be Yes/No under certain conditions, you could add a decision diamond to determine whether or not to update the yes/no field value:



If you are looking for something dynamic that can be determined before form submission, another option may be to add the custom yes/no field to your landing page form, and then pass a parameter to the landing page through the URL to determine what the value of that custom field should be.

I have added a custom yes/no field to a form on a Keap landing page and provided sample code below, showing how I updated, then hid that field based on the setToYes URL parameter:

I used the landing page ‘Code Snippet’ tool to add the following code to my Keap landing page:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

<script type="text/javascript">

        jQuery(document).ready(function() {	

            // Grab current URL with Parameters
            var urlToCheck = new URL(window.location);
                        
            /* If 'setToYes' URL Parameter passed with value
             of 'yes', check the 'Yes' Value */
            if((urlToCheck.searchParams.get('setToYes')) == 'yes') {
 
               jQuery('input#55').prop("checked", true);
                
            } // end if    

             // Hide the 'Yes/No' field from Landing Page
              jQuery('input#55').parent().parent().parent().hide();

        }); // end jQuery
        
</script>

The code checks to see if the landing page URL ‘setToYes’ parameter has the value of ‘yes’. If so, this field gets updated.

The code also hides the custom field so this can not be changed during the landing page submission. This part is optional, depending on what you’re trying to accomplish, but it sounds like you may not wish for them to change this value upon initial form submission.

Anyone using this code would need to find the ID of the ‘Yes’ input field for their custom field by inspecting the HTML and update accordingly. In my case, the ID was 55:

I do not claim to be an expert coder. Please feel free to review/update the code above as needed, or to get a second opinion. This code did work for me in my sandbox account, and I think it should put anyone looking to achieve what was being described on the right track.