# How to change the background color of the Button on clicking on OK button from Popup using CS\_Style

**URL:** <https://forum.inductiveautomation.com/t/how-to-change-the-background-color-of-the-button-on-clicking-on-ok-button-from-popup-using-cs-style/84238>\
**Category:** General Discussion\
**Tags:** perspective\
**Created:** [January 13, 2024, 12:43pm UTC](https://forum.inductiveautomation.com/t/how-to-change-the-background-color-of-the-button-on-clicking-on-ok-button-from-popup-using-cs-style/84238 "2024-01-13T12:43:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [January 13, 2024, 12:43pm UTC](https://forum.inductiveautomation.com/t/how-to-change-the-background-color-of-the-button-on-clicking-on-ok-button-from-popup-using-cs-style/84238/1 "2024-01-13T12:43:57Z")

</div>

Hi Team,  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/4/b491a501479eb15a283f131cb84487ea84d14a5e.png) ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/a/4aeca828f9a7163ac42777554603d9e42df548bd.png)

I have a Button1 as template in one view1 (Initially its background color is White)  
In view 2- I have flex container- binded Button1 and one more Button2  
View 3- is my Main View- View2 is binded  
In Main View (view3)- On clicking on Button1-I am opening Popup.  
In popup – on clicking on OK button, I am updating current time in database and also I need to change the Background color of Button1 depends on status column value in database.(If status=1 green(fromStyleCSS) else red)  
Script on Button1

```auto
system.perspective.openPopup("sampleform", 'Page/popup',params = {'param1’:value})

```

script on OK button:  
updating query.  
Created param for background color.  
Here How to change the background color of Button1 by using the style CSS created in Button1(View1).  
I tried with passing the parameter in popup for background color but not getting the result.  
Please guide.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 13, 2024, 12:52pm UTC](https://forum.inductiveautomation.com/t/how-to-change-the-background-color-of-the-button-on-clicking-on-ok-button-from-popup-using-cs-style/84238/2 "2024-01-13T12:52:07Z")

</div>

Use [Component Message Handlers](https://docs.inductiveautomation.com/display/DOC81/Component+Message+Handlers).

Read the docs and watch the videos.

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [January 13, 2024, 2:11pm UTC](https://forum.inductiveautomation.com/t/how-to-change-the-background-color-of-the-button-on-clicking-on-ok-button-from-popup-using-cs-style/84238/3 "2024-01-13T14:11:31Z")

</div>

Thank you.

I have tried this Message Handler method in other screens.  
But here already I am passing parameter in popup, so I want to know how we can use in this.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 13, 2024, 2:46pm UTC](https://forum.inductiveautomation.com/t/how-to-change-the-background-color-of-the-button-on-clicking-on-ok-button-from-popup-using-cs-style/84238/4 "2024-01-13T14:46:58Z")

</div>

If I understand your question, your situation is this:

```auto
View1 [Main]
  + View2
    + Embedded View: View 1
      + Button1
    + Button 1 - opens popup
    + Button 2

Popup
  + OK_button - needs to change View2/Button1 background color.

```

You seem to be trying to pass a value from Popup back to View1/View2/Button1. You can't pass values back through parameters. They are read only.

The correct way to do this is via message handling.

If my project tree is not correct then please clarify.

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [January 13, 2024, 5:15pm UTC](https://forum.inductiveautomation.com/t/how-to-change-the-background-color-of-the-button-on-clicking-on-ok-button-from-popup-using-cs-style/84238/5 "2024-01-13T17:15:44Z")

</div>

View1 - Button1  
View2- Flexrepeater - View1:Button1  
Testpage - View2 - Button1-openPOPup

on popup- Ok button- on click event- change the background color of Button1.

Thanks.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 13, 2024, 5:24pm UTC](https://forum.inductiveautomation.com/t/how-to-change-the-background-color-of-the-button-on-clicking-on-ok-button-from-popup-using-cs-style/84238/6 "2024-01-13T17:24:24Z")

</div>

The indentation to show the hierarchy - if you had any - would be lost in your post. You need to use the \</\> code formatting button. See [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831). Please edit your post to fix it.

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [January 13, 2024, 8:44pm UTC](https://forum.inductiveautomation.com/t/how-to-change-the-background-color-of-the-button-on-clicking-on-ok-button-from-popup-using-cs-style/84238/7 "2024-01-13T20:44:42Z")

</div>

Ok I will.  
Can you please guide how we apply using MessageHandler or other method for background color change of button.

View1 - button1  
clicking on button1- openpopup(view2)  
on popup - OK button click event- change the background color of Button1 in view1

Thank you
