I'm working on a form that askes the user what kind of "samples" of countertops they like.
Here is the page: https://topsc.webflow.io/pages/onboarding
I'm using Webflow CMS and some jQuery to automatically name the checkboxes that toggle whether or not they like certain samples. To make it easier for the company to see what's been checked, I'm trying to prevent all checkboxes that aren't checked from being submitted at all. I know a "select" form input is built for this, but that won't work for this UX setup.
Here is the code I wrote to rewrite all of the "name" attributes and an attempt to "disable" the inputs, but they're still being submitted.
$('.checkbox').each(function() {
$(this).siblings("div").children('input').attr("data-name", $(this).siblings('span').text());
$(this).siblings("div").children('input').attr("name", $(this).siblings('span').text());
$(this).siblings('div').children('input').attr("disabled", "disabled");
$(this).attr("name", $(this).siblings('span').text());
$(this).attr("data-name", $(this).siblings('span').text());
});
$('.checkbox').on('click', function() {
if ($(this).prop("checked")) {
$(this).siblings('div').children('input').removeAttr("disabled");
} else {
$(this).siblings('div').children('input').attr("disabled", "disabled");
}
});
The form submission data contains values for every input still, making it hard to parse as a human lol.
This could be an issue with Webflow's form handling, but I'm hoping for a workaround either way.