Change checkbox value

Hi everyone,
Can someone help me how to change the checkbox value?
This is my situation:
I am creating a form where users will need to select multiple solutions and i need the form to return the value of their selection instead of a boolean. I have created three checkboxes and the result of the selected checkbox is True i want to change that value into the label name.

Here is my read only link:
https://preview.webflow.com/preview/pixyle?utm_medium=preview_link&utm_source=designer&utm_content=pixyle&preview=02afd4fba9101c2f9e6ed17d2940d07d&pageId=61deb1d9de180c0123ba4187&workflow=preview

Thank you in advance

Hey @Ivana-Tosheva what you’re looking for to accomplish this is a select element with the “multiple” attribute.

You can enable multiple selection and define the value of each option.

Here’s what it looks like with a multiple selection.

Hope this helps. I know it’s not the same visual as checkboxes but is the standard and accessible way to create this functionality in web forms.

Dear @matthewpmunger ,

First of all thank you for your reply. I know about this solution but our graphic designer decided the form to be with checkboxes so i must find some solution about it. Can i change the value thru Zapier formatter? If yes how can i do it? Does the value can be changed with some JS custom code?

Thanks again, looking forward for your response again.

Yes, you could use Zapier or Integromat to combine the fields into a single line of text. There could be a potential solution with custom code. Would you like me to move this post to the Custom Code category?

@matthewpmunger
Yes, you can move the post it may be useful for me. And can you please send me some instruction or tutorial how can i do it with Zapier? Thank you in advance.

Hey any news on this? I have the same issue

I did not find the solution yet, if you have any news please write on this topic.

<script>
document.addEventListener("DOMContentLoaded", function() {

  // Set Form ID

  var form = document.getElementById('form');
  
  form.addEventListener('submit', function(e) {

    e.preventDefault();
    
    // Target checkboxes by their specific name attributes or a class if they have one

    var checkboxes = form.querySelectorAll('input[type="checkbox"]');
    
    checkboxes.forEach(function(checkbox) {
      if (checkbox.checked) {
        // Use the 'data-name' attribute for the checkbox value if it's checked
        checkbox.value = checkbox.getAttribute('data-name');
      } else {
        // If a checkbox is not checked, you might decide to not submit it, or submit with a value indicating it's not checked
        // Here, we're choosing not to modify unchecked checkboxes. Adjust according to your needs.
      }
    });
    
    // Debug: Log the FormData to see what's being submitted. Remove this in production.
    var formData = new FormData(form);
    for (var pair of formData.entries()) {
      console.log(pair[0]+ ', ' + pair[1]); 
    }
    
    // Submit the form
    form.submit();
  });
});
</script>





Set the Webflow Checkbox Custom attribute to data-name=“the name you want to send instead of on/off”.

Instead of CheckboxName=“on”, you will receive CheckboxName=“whatever name you set in the custom attributes”. You will need to name each individual checkbox like this, and the script will replace “on” with the name you set.