Target text widgets with a variable

Is possible to target a widget that can display text (in my case a label or headings) by a variable.
eg: Set text on [[X]] equal to “[[Y+1]]”

my goal is to be able to change X each time a particular case changes.

Any workaround?

Thank you,

Ram

Hi!

You can do this with a little javascript injected into the Open Link command (which runs the javascript instead of opening the link). Not that this will not work if the text of the target object is blank when you publish or share it. (If you want it to look blank, put a space in there.)

Live sample

File: set text of object by object name.rp (53.5 KB)

1 Like

Thank you, I will play around with this and see how I can incorporate it.

How would you modify the syntax to work on this instance:

Here is a little user story:
-my app has a dynamic panel with employee badges.
-Each employee also has a results page that displays their performance.
-There is slider that is used to give points to employees (rate them)
-The user will first select which employee to rate and then use the slider to assign the points. The employee’s result will then be updated accordingly.
-The points accumulate overtime

I think the JS syntax you gave me should work but I must be doing something wrong.
Here is what I did:
javascript:
$(’[data-label="[[placeholder]]"]’).html(’[[employeePoints+X]]’);
void(0);

[[placeholder]] is a global variable the slider is using while waiting on an employee selection
[[employeePoints]] is the variable the slider uses to grab the selected employee’s current points (assigned onclick on the employee badge), add the rating value X selected on the slider, then paste it on the [[placeholder]]

I set up an onclick interactions on each employee badge that sets the value of [[placeholder]] to an LVAR representing the selected employee’s result label. This onclick also assigns the selected employee’s current points to [[employeePoints]]

I hope this makes sense.

Thank you

Hi!

Is X a global variable?

X is not a variable. It will be the actual value selected on the slider (0, 1, 2, or 3)
so the slider will have cases that has the JS syntax with the respective value selected.

Okay. X needs to either be a global variable or a local one. You can’t simply refer to other objects by their name. Local variables are used to get values from other objects in an expression. See this post. Using local variables, This, and Target

What I meant was that I put x up top just to not a specific number. It will actually be a constant for the respective case. I did find a workaround by giving the slider a “memory” to store the rating and then passing it on to the employee afterwards. I am still in the process of learning Javascript so I will start using down the road I am sure.
Thank you for your help!