# How to change the button icon based on the value of the database?

**URL:** https://community.thunkable.com/t/how-to-change-the-button-icon-based-on-the-value-of-the-database/1795565
**Category:** Questions about Thunkable X
**Tags:** design, beginner, help
**Created:** [March 22, 2022, 6:32am UTC](https://community.thunkable.com/t/how-to-change-the-button-icon-based-on-the-value-of-the-database/1795565 "2022-03-22T06:32:04Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![dhanushan48608nkfw](https://avatars.discourse-cdn.com/v4/letter/d/fbc32d/32.png) [@dhanushan48608nkfw](https://community.thunkable.com/u/dhanushan48608nkfw)
#### Post date: [March 22, 2022, 6:32am UTC](https://community.thunkable.com/t/how-to-change-the-button-icon-based-on-the-value-of-the-database/1795565/1 "2022-03-22T06:32:04Z")

</div>

This is my 3rd question and thanks for previous helps.

In my app the cart should have 2 icons. If the cart is empty the icon should be “Empty cart pic” and if it has something in it the icon should be “Cart with products”.

The problem is, the code i made is working well when i restart the app, but it’s not working when i go beck from ‘ADDING THINGS TO CART’ to ‘DASHBOARD’(This is where the cart button exist).

And i’m little confused between the functions (of screens) Starts & Open.

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 22, 2022, 6:39am UTC](https://community.thunkable.com/t/how-to-change-the-button-icon-based-on-the-value-of-the-database/1795565/2 "2022-03-22T06:39:25Z")

</div>

> [@dhanushan48608nkfw](#):
>
> it’s not working when i go beck from ‘ADDING THINGS TO CART’ to ‘DASHBOARD’

Your code to change the icon should be in the `Screen Opens` block.

---

<div class="post-metadata">

### Author: ![dhanushan48608nkfw](https://avatars.discourse-cdn.com/v4/letter/d/fbc32d/32.png) [@dhanushan48608nkfw](https://community.thunkable.com/u/dhanushan48608nkfw)
#### Post date: [March 22, 2022, 8:14am UTC](https://community.thunkable.com/t/how-to-change-the-button-icon-based-on-the-value-of-the-database/1795565/3 "2022-03-22T08:14:42Z")

</div>

No, it’s not working

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 22, 2022, 8:29am UTC](https://community.thunkable.com/t/how-to-change-the-button-icon-based-on-the-value-of-the-database/1795565/4 "2022-03-22T08:29:03Z")

</div>

You need to show your code or create a simple project that demonstrate the issue and share this project someone can have a look and correct it.

---

<div class="post-metadata">

### Author: ![dhanushan48608nkfw](https://avatars.discourse-cdn.com/v4/letter/d/fbc32d/32.png) [@dhanushan48608nkfw](https://community.thunkable.com/u/dhanushan48608nkfw)
#### Post date: [March 24, 2022, 8:28am UTC](https://community.thunkable.com/t/how-to-change-the-button-icon-based-on-the-value-of-the-database/1795565/5 "2022-03-24T08:28:57Z")

</div>

Here it is,

 ![image_2022-03-24_135833](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/2/a25a9ee4cae939c661d30cb7a3fdfcf1583791a8.png)  
 ![Capture](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/6/e682024e133bc21360c645c187864cfc1ee28e97.png)

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 24, 2022, 8:56am UTC](https://community.thunkable.com/t/how-to-change-the-button-icon-based-on-the-value-of-the-database/1795565/6 "2022-03-24T08:56:41Z")

</div>

This does not provide any clarity.

Use labels inside your code blocks to show what is going on with it.

When testing avoid having **two** functions running immediately after each other.

If you are deleting a record from your `cart` table just before switching to the other screen, this could prevent your function from evaluating properly.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)
#### Post date: [June 22, 2022, 8:57am UTC](https://community.thunkable.com/t/how-to-change-the-button-icon-based-on-the-value-of-the-database/1795565/7 "2022-06-22T08:57:25Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
