# Basic question: Setting field value from a button

**URL:** <https://forum.bubble.io/t/basic-question-setting-field-value-from-a-button/1980>\
**Category:** Uncategorized\
**Created:** [March 14, 2016, 10:32am UTC](https://forum.bubble.io/t/basic-question-setting-field-value-from-a-button/1980 "2016-03-14T10:32:00Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![NigelG](https://avatars.discourse-cdn.com/v4/letter/n/ea5d25/32.png) [@NigelG](https://forum.bubble.io/u/NigelG)\
**Post date:** [March 16, 2016, 7:40am UTC](https://forum.bubble.io/t/basic-question-setting-field-value-from-a-button/1980/10 "2016-03-16T07:40:45Z")

</div>

I did it when I created the workflow for the button.

The action I chose on "When Button Is Clicked " was to “Set a State”.

![](https://us1.discourse-cdn.com/bubble/original/2X/3/3693a4eed99792f2c9dc803b7b419ff423a74069.png)

![](https://us1.discourse-cdn.com/bubble/original/2X/2/2d31aca341545d975e835486dea6ec79d18b884b.png)

I then created the state called Text of type “Text” right there. I attached it to the page (bit of an odd concept, but all variables/states need homes in Bubble). So that is why it is state Text (what I called it) of Swap (the name of the page).

![](https://us1.discourse-cdn.com/bubble/original/2X/0/0e6babcefde68cc58844addf04ec33a71ebb8fc5.png)

The action on the button then moves the field A text into the variable/state.

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

This variable/state is now available to other elements or workflows.

So I just set up the Input B field to take this variable/state as a default (Initial Content).

![](https://us1.discourse-cdn.com/bubble/original/2X/4/4a6b96c823bd614d0694ba25859fd82a68898548.png)

I am sure you recognise the concept of individual “objects” having their own data. So a page can have a “state” of EditMode set to yes or no. Or a button can have a count of the number of clicks it has received.

But we also use the states as temporary variables for the page.

So here …

![](https://us1.discourse-cdn.com/bubble/original/2X/7/71c8cc34d6324478027987dfc2ffe1b684e73af8.png)

… I am using a state that is a list/array of things/objects to store a temporarily selected list. Each time the user checks a checkbox, that checkbox’s fruit object is added (:plus) to the list.

---

_[View the full topic](https://forum.bubble.io/t/basic-question-setting-field-value-from-a-button/1980)._
