# Changing a Tag value with a component - Perspective

**URL:** <https://forum.inductiveautomation.com/t/changing-a-tag-value-with-a-component-perspective/52069>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [October 18, 2021, 6:29pm UTC](https://forum.inductiveautomation.com/t/changing-a-tag-value-with-a-component-perspective/52069 "2021-10-18T18:29:14Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![laurie.croteau](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@laurie.croteau](https://forum.inductiveautomation.com/u/laurie.croteau)\
**Post date:** [October 18, 2021, 6:29pm UTC](https://forum.inductiveautomation.com/t/changing-a-tag-value-with-a-component-perspective/52069/1 "2021-10-18T18:29:14Z")

</div>

Hi everyone,

I’m trying to related the value of my dropdown to a tag. So, if I choose the first item of my dropdown, my tag value would be 0 and if I choose the second item of my dropdown, my tag value would be 1. I did a OnChange script, it work when I do preview mode, but doesn’t when I’m in a browser.

Thank you all for your help.

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [October 18, 2021, 6:52pm UTC](https://forum.inductiveautomation.com/t/changing-a-tag-value-with-a-component-perspective/52069/2 "2021-10-18T18:52:19Z")

</div>

Have you considered using a bidirectional tag binding?

[https://docs.inductiveautomation.com/display/DOC81/Tag+Bindings+in+Perspective](https://docs.inductiveautomation.com/display/DOC81/Tag+Bindings+in+Perspective)

---

<div class="post-metadata">

**Author:** ![laurie.croteau](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@laurie.croteau](https://forum.inductiveautomation.com/u/laurie.croteau)\
**Post date:** [October 18, 2021, 7:12pm UTC](https://forum.inductiveautomation.com/t/changing-a-tag-value-with-a-component-perspective/52069/3 "2021-10-18T19:12:09Z")

</div>

Thanks, it work!  
But it takes like 5 seconds to my label to set. In this 5s, labels are switching rapidly between English and French, do you know why?

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [October 18, 2021, 8:12pm UTC](https://forum.inductiveautomation.com/t/changing-a-tag-value-with-a-component-perspective/52069/4 "2021-10-18T20:12:43Z")

</div>

I don’t know for sure. Did you make sure to remove your tag change script when you introduced the binding?

---

<div class="post-metadata">

**Author:** ![laurie.croteau](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@laurie.croteau](https://forum.inductiveautomation.com/u/laurie.croteau)\
**Post date:** [October 19, 2021, 1:55pm UTC](https://forum.inductiveautomation.com/t/changing-a-tag-value-with-a-component-perspective/52069/5 "2021-10-19T13:55:55Z")

</div>

Yes I did

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [October 19, 2021, 2:05pm UTC](https://forum.inductiveautomation.com/t/changing-a-tag-value-with-a-component-perspective/52069/6 "2021-10-19T14:05:43Z")

</div>

What labels ? Are they displaying data related to the tag you’re changing ?  
How do you handle translation - is it a global translation, or are you using the `translate()` expression function ?

---

<div class="post-metadata">

**Author:** ![laurie.croteau](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@laurie.croteau](https://forum.inductiveautomation.com/u/laurie.croteau)\
**Post date:** [October 19, 2021, 2:10pm UTC](https://forum.inductiveautomation.com/t/changing-a-tag-value-with-a-component-perspective/52069/7 "2021-10-19T14:10:56Z")

</div>

They are simple label components. I enter all my translation into the `Translation Manager` and with my dropdown I change the `session.props.locale` value between “fr” and “en-US”.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [October 19, 2021, 2:17pm UTC](https://forum.inductiveautomation.com/t/changing-a-tag-value-with-a-component-perspective/52069/8 "2021-10-19T14:17:53Z")

</div>

So the dropdown is used to select the display language, or is that a different dropdown ?  
If that’s the dropdown you were talking about, what’s that tag you are trying to modify supposed to do ?

---

<div class="post-metadata">

**Author:** ![laurie.croteau](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@laurie.croteau](https://forum.inductiveautomation.com/u/laurie.croteau)\
**Post date:** [October 19, 2021, 2:32pm UTC](https://forum.inductiveautomation.com/t/changing-a-tag-value-with-a-component-perspective/52069/9 "2021-10-19T14:32:35Z")

</div>

I only have one dropdown and I change the value of a memory tag (with bidirectional option).  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/0/60cf3cff2072980193473a4e799bccc9a85b1038.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/3/93b567e6e2c83412f2e5eb63aa35f3c3ee8b30c4.png)

This memory tag is relate in a script in the binding of `locale` (in session/props/locale).

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/3/6379e6e9d3ac882fa083b98f4d60e6ffc5fbc9be.png)

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [October 19, 2021, 2:40pm UTC](https://forum.inductiveautomation.com/t/changing-a-tag-value-with-a-component-perspective/52069/10 "2021-10-19T14:40:28Z")

</div>

Why don’t you just change the `session.props.locale` ? That’s what session properties are for, changing a tag will change the language in all clients. And it frankly makes things more complicated than they have to be…  
Or does the tag have some other use ?

I’d suggest you bind your dropdown directly to `session.props.locale`, and let it handle one and only one thing.  
Also, you might want to use `fr-FR` (or fr-CA, fr-BE, fr-CH…) instead of just `fr`.

I can also help you in french through private messages if you’d like, I’d rather keep the public forums english only.

---

<div class="post-metadata">

**Author:** ![laurie.croteau](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@laurie.croteau](https://forum.inductiveautomation.com/u/laurie.croteau)\
**Post date:** [October 19, 2021, 2:57pm UTC](https://forum.inductiveautomation.com/t/changing-a-tag-value-with-a-component-perspective/52069/11 "2021-10-19T14:57:18Z")

</div>

Thank you, it worked! I didn’t use that binding because I didn’t know I could 😅

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [October 19, 2021, 3:28pm UTC](https://forum.inductiveautomation.com/t/changing-a-tag-value-with-a-component-perspective/52069/12 "2021-10-19T15:28:20Z")

</div>

You’re welcome !  
Do change that ‘fr’ to ‘fr-FR’ though.

---

<div class="post-metadata">

**Author:** ![laurie.croteau](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@laurie.croteau](https://forum.inductiveautomation.com/u/laurie.croteau)\
**Post date:** [October 19, 2021, 3:47pm UTC](https://forum.inductiveautomation.com/t/changing-a-tag-value-with-a-component-perspective/52069/13 "2021-10-19T15:47:43Z")

</div>

What does it change?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [October 19, 2021, 4:04pm UTC](https://forum.inductiveautomation.com/t/changing-a-tag-value-with-a-component-perspective/52069/14 "2021-10-19T16:04:36Z")

</div>

That’s how we write locales. It makes it easy to see that it is indeed a locale, and some things need it to be in that format in order to parse it correctly.  
In your case it might not change anything, but complying to conventions when writing code is a good habit to have.
