Webflow form - Sending empty checkboxes?

Hey guys, so I have a Form in which I have a couple of checkboxes where the visitor can choose from.

The problem is that when the form gets submitted I get an email in which I get the “true” & “false” value of EVERY checkbox I have which is pretty annoying.

So my question would be is there a way where I can ONLY get the value I’ve selected from the Form as DISPLAYED on the Form.
So in my example, I would only get the value of “8e”, “11e” & “autre” with the form submission.

I really hope someone could help me with this:)

Thanks!

https://preview.webflow.com/preview/paris-project?utm_medium=preview_link&utm_source=designer&utm_content=paris-project&preview=04ac94a1fd2d03f1af29fef2c0f78338&pageId=5ffe1a2d4f68062a3bbf88f3&mode=preview&fbclid=IwAR2hv-EETORkBYAMYP7Vgngik0qCs_J3nl0AmC7ZZNlMzYctpLAbuNNMFCg

I tried about a million different methods before I finally found something that worked, and this really does! It removes all unchecked checkbox fields from the notification email. Hope this helps someone.

// To use:
// 1 - Replace "#your-form-id" with your actual form ID
// 2 - Put in Footer Code form field, save, and publish site

<script>
$(function() {
    $('#your-form-id').submit(function () {
        var $empty_fields = $(this).find(':checkbox').filter(function () { 
            return $(this).prop('checked') == false;
        });
        // without this, you get a flash of the form with unchecked fields removed
      	$(this).hide();
        // removes the unchecked items
        $empty_fields.remove();
        // allows the form to run as normal
        return true;
    });
});
</script>
1 Like

Hi Edward,
I’m trying your solution right now and I can’t seem to get it to work… What do you mean by “Footer Code form field”?
I tried putting the custom code in the tag, before the tag and as an embed element in the form itself (not all at once ofc). I’m fairly certain I’ve replaced the form id correctly so I feel like I’m just inserting the code in the wrong place.

@vuz - you can just place it in the custom code area before the closing body tag on the page. You open up the navigator and click the gear icon next to the page:

image

I think the only important thing to change in this script is the form id.