Streaming live at 10am (PST)

"true" / "false" converted to "yes" / "no" on form submission

Hi there :slight_smile:

I was wondering, if there were an option to write a tiny jquery script to convert the values of true respectively false of a checkbox into yes respectively no when Webflow submit the forms ?

Thank you for any tips !
Anthony

1 Like

Did you find an answer ? :slight_smile:

Seems a bit dicey…

I don’t know of any way to specify those values in in the HTML element itself, which means that the web browser itself is generating true | false on the form submission. If you’re using Webflow’s in-built form submit, I believe that’s AJAX-based (?) which means changing those values might have further undesirable consequences in webflow’s handling of your form data.

Instead, consider these cleaner approaches-

  1. Use radio buttons instead. Takes slightly more space, but you get to choose the values that are passed through. Takes a bit more space visually, but still requires only one click from the user.
  2. Use a dropdown select instead. Same advantage, same clean output, just a different presentation. Requires 2 clicks, one to open the select, and one to choose the option you want.

If you’re set on using a checkbox, but need an on or off value in your data, here’s a different approach that could work for you…

  • Create a hidden field using a Embed element. Give it the name you want your resulting on | off value to appear as.
  • Keep your checkbox element, but name it something different, so it doesn’t compete with your hidden value storage element.
  • Write some jQuery that captures your checkbox click events, and sets the on | off value you want on your hidden element.

Voila, you have have a checkbox control, with a custom value in your form data.

Note that when the form is submitted, you’ll get both values, e.g…

myvalue=on
chk_myvalue=true