Join the Webstudio community

Updated 2 months ago

Form checkbox

At a glance
Hi guys

Here is my form and I've got a checkbox. I want to retreive the value of the checkbox. You've got my config in attachment.

When I test it with a webhook (on webhook.site), here is what I've got :
  • When it's check I've got terms-checkbox="on"
  • When it's NOT check I cannot retreive the value (who should be "off" ?)
So I've got 2 questions:

1/ I would prefer to get true or false when it's check or not. Do you know if it's possible to have theses value rather "on" or "off"?

2/ When the checkbox is NOT fill and I press submit, the checkbox value is not send. Do you know why?

Thanks a lot πŸ™‚
Attachment
SCR-20241102-lpdt.png
B
M
J
5 comments
This is how checkbox works, either sends value or omits it. What you want is radio with two options. Though it is tricky to style as singular control.
Though on backend you can always coalesce missing value with default one.
ok @TrySound. thanks a lot. I didn't know about that! I learnt something πŸ™‚

Next time I will check the MDN page which is pretty clear about my question. Sorry for that and thanks!
With react framework we forget about this too every time πŸ™‚
I ran into this years ago and found something that didn't make sense to me. Inspect a checkbox with your dev tools. Check them on and off. You'll see no difference.

I completely forget why it's this way or the solution. Just pointing out a possible reason... πŸ˜›
Add a reply
Sign up and join the conversation on Discord