I am using a Form checkbox and using the following code…
document.getElementById('chackbox-id').checked = "true";
The only way the above code works is if I use a custom code to create the checkbox and not use the Form checkbox. The problem with that is I can’t figure out how to style the checkbox when checked.
<input type="checkbox" id="checkbox-id">
Here is a screen of the Ui I am trying to build with Webflow…
Any Help is Appreciated!
hi @Rafael and welcome to forum.
- you have
- you can set option
custom checkbox in WF.
- add embed element to add custom CSS to style your checkbox the way you need
Hi, thanks for the reply!
Not sure if I explained my problem correctly…
This was a typo.
var alpha = document.getElementById('alpha').checked
But, can’t use code below to turn checkbox on or off
document.getElementById('alpha').checked = true;
hi @Rafael It is hard to debug just from UI image when there is no code to check.
You can use JS loop eg.
forEach to add click eventListener to listen for change and that use eg. Ternary operator to switch states or do whatever you need. Debugging only from short description with one line of code without context is more just guess than valuable help or advice.
Webflow has its own rules on predefined elements and on checkbox
div element adding class
w--redirected-checked when checkbox is active. This mean there is no attribute
checked on checkbox input field.
So if you know how to code I will recommend use as less WF predefined elements as you can.
I think this is the solution to my problem. Thank you very much for the help!
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.