# How to Assign a value to checkbox

**URL:** <https://forum.bubble.io/t/how-to-assign-a-value-to-checkbox/7839>\
**Category:** Need help\
**Created:** [November 13, 2016, 11:28pm UTC](https://forum.bubble.io/t/how-to-assign-a-value-to-checkbox/7839 "2016-11-13T23:28:50Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![shadsanders89](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@shadsanders89](https://forum.bubble.io/u/shadsanders89)\
**Post date:** [November 13, 2016, 11:28pm UTC](https://forum.bubble.io/t/how-to-assign-a-value-to-checkbox/7839/1 "2016-11-13T23:28:50Z")

</div>

I am trying to create a menu using a repeat group. In that group I have the service name and price with a checkbox. When the checkbox is clicked I would like the price of the associated service to be added to the total. Any advice on how to accomplish that?

---

<div class="post-metadata">

**Author:** ![fayewatson](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/fayewatson/32/2686_2.png) [@fayewatson](https://forum.bubble.io/u/fayewatson)\
**Post date:** [November 14, 2016, 1:19am UTC](https://forum.bubble.io/t/how-to-assign-a-value-to-checkbox/7839/2 "2016-11-14T01:19:16Z")

</div>

Hello 🙂 One way to do this is to use a custom state which will hold a list of ‘checked’ Services. Custom states are great because they allow us to ‘store’ which Services a User has selected (until the page is refreshed), and custom states will not cost you any workflows since you’re not making any changes to the database. Here is an example in the forum app:

Preview:

> **[Bubble - Visual Programming](https://forumapp3.bubbleapps.io/version-test/checked_services)**
>
> Build stuff without code and launch a startup without a tech-cofounder! Bubble is a visual programing language. Instead of typing code, use a visual editor to build applications.

Editor:

> **[Bubble Editor - Forumapp3](https://bubble.io/page?type=page&name=checked_services&id=forumapp3&tab=tabs-1)**
>
> Build stuff without code and launch a startup without a tech-cofounder! Bubble is a visual programing language. Instead of typing code, use a visual editor to build applications.

Here is a step-by-step:  
To replicate this, you would set up a workflow which happens when the checkbox’s value is changed. For example, you would select “Elements → When an Input’s Value is Changed → Element: Checkbox”

![](https://us1.discourse-cdn.com/bubble/original/2X/7/77e222574528ae171a2f302387344845153ebe6c.jpg)

![](https://us1.discourse-cdn.com/bubble/original/2X/5/5e16999b8f1a004e7da0600b4959819fb1b33a5b.jpg)

In the above screenshots we’re just creating the When statement for when the Checkbox goes from ‘Unchecked’ to ‘Checked’. Then you’d create an action in the workflow which adds the Current cell’s service to the Selected List of Services. First, we need to set up the custom state List of Services. To do this, you would go to Element Actions → Set State → Element: checkbox\_services, Custom state: Create a new custom state…  
 ![](https://us1.discourse-cdn.com/bubble/original/2X/c/cbbf92caeb247287663cf50cc14f137dbde3cc42.jpg)

![](https://us1.discourse-cdn.com/bubble/original/2X/6/6fbbd2805d018b9bce115d3364b48589b7371dbb.jpg)

Here we’re creating the custom state List of Services on the page itself (the page’s name is checkbox\_services). Bubble allows us to create a custom state on any element, and the page is considered an element. We don’t want to set the custom state on the checkbox, because it won’t be accessible to retrieve it’s information using an outside text element, since the checkbox itself is inside of the repeating group.

After the custom state List of Selected Services on the page is created, the next step is to tell Bubble what the value of that List should be when a checkbox is checked. Since we need the Current cell’s Service to be added to our list when this happens, the value of the custom state is: “Checked\_Service’sSelectedServices:plus item Current cell’s Service”.

 ![](https://us1.discourse-cdn.com/bubble/original/2X/2/20106c807030f42c35dafe5682ea59073c1e9938.jpg)

This value tells Bubble to add (or “:plus”) the Current cell’s service to our Selected Services List when a User clicks a checkbox to go from unchecked to checked. Alternatively, we need to set up another workflow which will ‘minus’ a Service from the Selected Services list if a checkbox goes from checked to unchecked (the User is trying to deselect a Service). To do this, we’d set up another workflow where the ‘When’ is: Elements → An input’s value is changed → Element: Checkbox and This Checkbox isn’t checked:

![](https://us1.discourse-cdn.com/bubble/original/2X/4/42463d415abe672a768a720c3f364f76491f5681.jpg)  
 ![](https://us1.discourse-cdn.com/bubble/original/2X/7/71593d5bab5fb58d3c235ff417d0a085ef1d5ba0.jpg)

Everything is the same for setting the state on the Checkbox, and changing our Selected Services list. The only thing that’s different here will be the value (since we’re not doing :plus Current cell’s Service; we need the service to be filtered out from our list):

 ![](https://us1.discourse-cdn.com/bubble/original/2X/8/835ae9cac7b1b561f16d3d3fb379737da32096db.jpg)

This part is a little tricky because there isn’t a :minus option to remove a Service from the Selected Services list. As a workaround, we are going to use the :filtered option below:

 ![](https://us1.discourse-cdn.com/bubble/original/2X/8/81f210d95d38efdce40d87a8ea01460590a76630.jpg)

This looks confusing at first, but this :filtered option is stating that the value of our Selected Services list cannot contain any Services whose unique ID matches the ‘Current cell’s Service’s unique ID’ (the Service that the User just ‘unchecked’).

Now that the workflows for checking and unchecking a service are set up, I created a repeating group and a text element on the right side of the page which display the Services a User has selected in the repeating group, and the total price of the Selected Services in the text element.

The data source for the repeating group is our Checkbox’s Selected Services (shown below):

 ![](https://us1.discourse-cdn.com/bubble/original/2X/4/4429140e937be61175e7930ba77352e55106a110.jpg)

And the text element will display the :sum of the Selected Services “Price” field. In this example, I set every Service to be $10.

 ![](https://us1.discourse-cdn.com/bubble/original/2X/a/a098e9ce12e0be05c2db4141544d9a5151f1bd9e.jpg)

And that should work as expected! If you have absolutely any questions or if any of this was confusing please feel free to let me know. It takes a little while to set up at first, but will definitely become easier after setting this up a few different times. 🙂

---

<div class="post-metadata">

**Author:** ![shadsanders89](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@shadsanders89](https://forum.bubble.io/u/shadsanders89)\
**Post date:** [November 15, 2016, 3:49am UTC](https://forum.bubble.io/t/how-to-assign-a-value-to-checkbox/7839/3 "2016-11-15T03:49:34Z")

</div>

Thank you a lot. I’m going to give this a try!

---

<div class="post-metadata">

**Author:** ![liam.j.brien](https://avatars.discourse-cdn.com/v4/letter/l/e495f1/32.png) [@liam.j.brien](https://forum.bubble.io/u/liam.j.brien)\
**Post date:** [December 13, 2017, 12:21pm UTC](https://forum.bubble.io/t/how-to-assign-a-value-to-checkbox/7839/4 "2017-12-13T12:21:50Z")

</div>

Blown away by the level of detail in your answer.  
Thank you!!

---

<div class="post-metadata">

**Author:** ![anon18390936](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@anon18390936](https://forum.bubble.io/u/anon18390936)\
**Post date:** [February 27, 2018, 12:11pm UTC](https://forum.bubble.io/t/how-to-assign-a-value-to-checkbox/7839/5 "2018-02-27T12:11:40Z")

</div>

Hi,  
I’m digging up this thread as I have tried to implement this solution on my app : [https://bubble.io/page?type=page&name=index&id=scenarios&tab=tabs-1](https://bubble.io/page?type=page&name=index&id=scenarios&tab=tabs-1)

The Checked workflow seems to work just fine, however the checked\_options state does not seem to filter properly on “uncheck”, the display groups seem to be a bit funny… not sure where my error is, if someone could point me in the right direction it would be much appreciated !!  
Thanks a lot !

---

<div class="post-metadata">

**Author:** ![fayewatson](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/fayewatson/32/2686_2.png) [@fayewatson](https://forum.bubble.io/u/fayewatson)\
**Post date:** [February 27, 2018, 11:01pm UTC](https://forum.bubble.io/t/how-to-assign-a-value-to-checkbox/7839/6 "2018-02-27T23:01:37Z")

</div>

Hey @anon18390936 🙂 Can you share some screenshots of the workflow you have when an element is unchecked? Or set the app to public by going to (Settings --\> General --\> Application Rights --\> Everyone Can View)

---

<div class="post-metadata">

**Author:** ![anon18390936](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@anon18390936](https://forum.bubble.io/u/anon18390936)\
**Post date:** [February 28, 2018, 7:42am UTC](https://forum.bubble.io/t/how-to-assign-a-value-to-checkbox/7839/7 "2018-02-28T07:42:57Z")

</div>

Hi, I have actually made a workaround by creating a thing to store checked values and modifying it on check/uncheck, instead of a custom state, so that seems to do the job for now… I will explore states when i’m not in such a rush ! 😉  
Happy to share my (not so elegant and a bit cumbersome) solution if someone needs it…  
thanks  
Marj

---

<div class="post-metadata">

**Author:** ![valeri.kopaleishvili](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/valeri.kopaleishvili/32/23932_2.png) [@valeri.kopaleishvili](https://forum.bubble.io/u/valeri.kopaleishvili)\
**Post date:** [July 2, 2018, 2:31pm UTC](https://forum.bubble.io/t/how-to-assign-a-value-to-checkbox/7839/8 "2018-07-02T14:31:41Z")

</div>

Hi  
your post is create but I still can’t find a solution in that case  
please take a look…  
Thanks!

---

<div class="post-metadata">

**Author:** ![fayewatson](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/fayewatson/32/2686_2.png) [@fayewatson](https://forum.bubble.io/u/fayewatson)\
**Post date:** [July 2, 2018, 9:48pm UTC](https://forum.bubble.io/t/how-to-assign-a-value-to-checkbox/7839/9 "2018-07-02T21:48:38Z")

</div>

Hi @valeri.kopaleishvili 🙂 I just took a look at the forum example again and it seems to be working, what is the question you have? Or did you mean to share a link to your app editor?

---

<div class="post-metadata">

**Author:** ![valeri.kopaleishvili](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/valeri.kopaleishvili/32/23932_2.png) [@valeri.kopaleishvili](https://forum.bubble.io/u/valeri.kopaleishvili)\
**Post date:** [July 3, 2018, 8:01am UTC](https://forum.bubble.io/t/how-to-assign-a-value-to-checkbox/7839/10 "2018-07-03T08:01:32Z")

</div>

Problem in my case is when user choose multipule checkboxes value is saved as a one string in the database not as a different seperate inputs ( i guess so)  
if i check only 1 checkbox its working and displays value correctly but in multiple case it doesn’t display any values  
for detials you can have a look on my post

> [@Checkbox list assign Value and display](http://forum.bubble.io/t/checkbox-list-assign-value-and-display/32560):
>
> Hi I have two mobile APPs which are connecting to each others through Bubble API connector (Company Side and User side) In user App I changed Dropdown “job category” to checkboxs where user is able to choose multiple choices, assined to each option and create custom state … also create a workflow when button ‘Save’ is clicked to save the data data saves in the database ( even if its multiple inputs) white_check_mark but data displays only if the input is only one, if there…

thank you!

---

<div class="post-metadata">

**Author:** ![valeri.kopaleishvili](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/valeri.kopaleishvili/32/23932_2.png) [@valeri.kopaleishvili](https://forum.bubble.io/u/valeri.kopaleishvili)\
**Post date:** [August 8, 2018, 1:47pm UTC](https://forum.bubble.io/t/how-to-assign-a-value-to-checkbox/7839/11 "2018-08-08T13:47:16Z")

</div>

What about if this checkbox value is stored in the database (when its checked)  
and  
what about if i want to delete this value from the database by unchecking this checkbox (value should be deleted)

---

<div class="post-metadata">

**Author:** ![kngf222](https://avatars.discourse-cdn.com/v4/letter/k/919ad9/32.png) [@kngf222](https://forum.bubble.io/u/kngf222)\
**Post date:** [August 11, 2020, 3:42pm UTC](https://forum.bubble.io/t/how-to-assign-a-value-to-checkbox/7839/12 "2020-08-11T15:42:05Z")

</div>

I have a repeating group with one checkbox on the left, text in the middle, and another checkbox on the right (the user is clicking one of the checkboxes, one being “good” and the other being “bad”). I need to have a “Submit” button at the end that allows the checkboxes’ results update numbers in the database for that user. How can I make this work?

---

<div class="post-metadata">

**Author:** ![marksrunge](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/marksrunge/32/84554_2.png) [@marksrunge](https://forum.bubble.io/u/marksrunge)\
**Post date:** [February 22, 2021, 7:48pm UTC](https://forum.bubble.io/t/how-to-assign-a-value-to-checkbox/7839/13 "2021-02-22T19:48:49Z")

</div>

The :minus has been added since this post was created so no need to filter 🙂  
Thank you so very much for such a detailed explanation.

---

<div class="post-metadata">

**Author:** ![marksrunge](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/marksrunge/32/84554_2.png) [@marksrunge](https://forum.bubble.io/u/marksrunge)\
**Post date:** [February 22, 2021, 7:57pm UTC](https://forum.bubble.io/t/how-to-assign-a-value-to-checkbox/7839/14 "2021-02-22T19:57:12Z")

</div>

Also, anyone who wants to actually write out the records from the state to a Thing (say on clicking a Save button) may be interested in this post:

> [@How do I create records from a list state?](http://forum.bubble.io/t/how-do-i-create-records-from-a-list-state/99243):
>
> I have a state that saves a table as a list, so when checking checkboxes on a repeating group it runs a workflow that adds the current row to the list state if it’s checked, and removes it if it’s unchecked. I need to run a workflow action now that creates a different record, and then relates it to the list state. So for example, if I check the box on 5 rows in the repeating group, it first adds all 5 rows to the state as a list (this works fine right now) but then I need the next step to be “…

---

<div class="post-metadata">

**Author:** ![esme\_borisoff](https://avatars.discourse-cdn.com/v4/letter/e/b782af/32.png) [@esme\_borisoff](https://forum.bubble.io/u/esme_borisoff)\
**Post date:** [September 8, 2021, 11:08pm UTC](https://forum.bubble.io/t/how-to-assign-a-value-to-checkbox/7839/15 "2021-09-08T23:08:52Z")

</div>

Hi I have a question about this response… How come your plus: is current cell’s service? I’m trying to use my checkbox to show only verified listings vs non verified. when I say plus: its not already focused on a particular cell…?
