[SOLVED] Set state of checkbox

How to state the state of checkbox via workflow action?

2 Likes

In the workflow, a checkbox’s “is checked” and “isn’t checked” is built in for ‘Do When Condition is True’ events:

Or, if you need the checkbox value to change via the workflow, you can set the Preset status to Dynamic:

Then you can have the Dynamic Status be the value of a custom state:

So for example, when Button is clicked → Set State → Element: Page, Custom State: “State”, Value: Yes.

When this workflow happens, the checkbox will go from unchecked to checked. (as long as the “State” is a “yes/no” type of field). :slight_smile: *Sorry for the multiple edits; I accidentally sent the post before I completed it!

5 Likes

Works like a charm, thank you!

2 Likes

No problem! :slight_smile:

@fayewatson

I am trying to change the state of the checkbox according to the change in the value of a radio button.

i tried using something like the above mentioned but couldn’t crack it. can you probably help me with the process for the same.

As per the above image, I would like to set the status of the checkbox to unchecked when i change the radio button’s value from prospect to engage and vice versa.

Thanks in advance for your help.

Hi @sriram :slight_smile: Sure thing! I just want to make sure I understand correctly, are you trying to show different elements to the Current User, based off of whether the Current User has selected “Prospect” or “Engage”? Or is this related to saving data? Just want to double-check since you may not need a custom state with your setup. :slight_smile:

@fayewatson

I have a radio button with a two types Prospect and Engage in it as options.

I also have two check boxes

  1. Decide Budget at adset level - This is visible when the radio button is Prospect
  2. Decide Budget at campaign level - This is visible when the radio button is Engage

Now when i check the checkbox it will either disable or enable the input box next to it.

The problem i am facing is that, say, When the check box is checked and then i change the radio button value the checkbox doesnt get unchecked. I would ideally want the checkbox to be unchecked when i change the radio button’s value since both the checkboxes have different workflows which changes the values of Input box. If one check box remains checked and the next checkbox is also checked then the input box doesnt do the required operation.

Hope this helps.

1 Like

Got it! Thanks! :slight_smile:

When the radio buttons are changed, do you need both of the Decide Budget at adset level and Decide Budget at campaign level checkboxes to go unchecked? Or just the Decide Budget at adset level?

I can actually get both the check boxes to go unchecked when the radio button is getting changed.

Is this functioning similar to the way you need it?

Preview:

Editor:

Here the checkboxes will both be unchecked when the radio button is changed. If one of the checkboxes is checked, and the Current User tries to click the second checkbox, the first checkbox becomes unchecked (preventing the Current User from selecting both checkboxes).

*Edit: I see the Current User wouldn’t be able to see both checkboxes at once, so reseting the checkboxes when the radio buttons are changed should ensure that the Current User can’t select the Adset level checkbox when Engage is selected, and also can’t select the Campaign level checkbox when Prospect is selected.

If that’s not how you need it to be please let me know and I’ll make adjustments! :slight_smile:

1 Like

@fayewatson

Thanks a lot, that solved my problem.

1 Like

Awesome! :slight_smile: No problem at all!

I am struggling too with checkbox. Is there a way to change the state of a checkbox by workflow, once it has already been checked/unchecked by clicking on it?
I want to control which items of a repeating group are checked. So I have at the top one “check all/uncheck all” checkbox, and beside every RG item its own checkbox. Furthermore, my RG is “splitted” into different page, so that not all the items are shown at the same time.
I want that if all the single items checkboxes are checked, the “check all” checkbox becomes checked. Or if I check the “check all” checkbox, all the (remaining if some is already checked) single item checbox turn checked. Same exact reverse thing for uncheck.
Now, I have associated a workflow to both the “check all” checkbox and the single RG item checkbox. When I check the “check all” checkbox, all the items (numbers) are pushed into a custom state list (through a recursive workflow). When I check the single RG item checkbox, that item (number) is pushed into the custom state list. Also here I have set the same exact reverse workflows for uncheck.
My “check all/uncheck all” is set with prestatus “dynamic”, where data source evaluates if the number of the items in the custom state list is equal to that of the repeating group.
The single RG item checkbox is set with pre status “dynamic” as well, where the data source evaluates if its number is or not into the custom state list.
Anyway, once I “play” a little bit by checking/unchecking both the all and the single item RG checkboxes, it fails, i.e. I don’t get the behaviour I would have liked. It looks to me that, once the checkbox has been clicked, it is focused and it doesn’t answer anymore to the dynamic status. Checking the inspector, furthermore, I sometimes get that a checkbox has actually a status opposite to that it should have (i.e. the status is checked while the checkbox is unchecked).
Any ideas? Thank you very much!

I have noticed one (strange for me) thing about checkbox in Bubble: if you inspect the checkbox element in dev tools, the corresponding html element never gets the attribute “checked”, that should exists whenever one clicks on (checks) it. Even if I add manually the “checked” attribute, the checkbox element doesn’t change its state. If I do the same exact thing in a html document I get instead that the checkbox state is driven by the presence (or absence) of the “checked” attribute…

I found the solution if someone else will read my posts…in order to make the checkboxes follow their dynamic status data source, whenever one is clicked, the other affected by this click, must be resetted. In my case I used a reset input for the “check all/uncheck all” checkbox, that is in a group always visible at the top. For the single item checkboxes inside the RG, I have put the RG itself inside a group and when I click on the “check all/uncheck all” checkbox, this trigger a reset data, where the lement to be resetted is the Group that contains the RG. This, in my case, causes also to go back to the first page of the RG. So, to avoid this, I keep track of the current RG page in a custom state and, when I reset the Group data, I also trigger a “go to page” for the RG.

Thanks for updating with your workaround. This is certainly a bug in that the checkbox does not stay bound to the state when using a dynamic status.

I found your instructions a bit difficult to understand, so I’ll summarize how I fixed this.

What I was trying to do is, within a repeating group (RG), have another button within each control the state of each one of my checkboxes. The way that I did this is:

  1. Add a state to the checkbox of “checked”, and set the checkbox to the dynamic status of that state.
  2. Add 4 (2x2) workflows, one each for the checked and unchecked states (2) FOR EACH clicking on the button and clicking on the checkbox itself.
  3. The workflows for clicking on the button were (a) On click: When checked state is “yes” → (i) Reset relevant inputs (ii) set “checked” state to “no”. (b) On click: When checked state is “no” → (i) Reset relevant inputs (ii) set “checked” state to “yes”.
  4. The workflows for clicking on the checkboxes were (a) On value change: When Checkbox is checked (This is NOT the custom “checked” state, but the internal state of the checkbox) → (i) Set checked state to “yes” (b) On value change: When checkbox is NOT checked (This is NOT the custom “checked state”, once again) (i) Set checked state to “no”.

With these 4 workflows and the custom state, I am able to have the button AND the checkbox itself control the checked/not checked visibility and state of the checkbox itself and do other things with these workflows (like set values on things or change other elements).