Read Global Variable value and put it in the text

advanced-prototyping

#1

Hello there,

I am using a global variable to count how many items checked and I can see this value in the prototype view being counted correctly. But I can’t figure out how to put this number to a different place.

If you look at the screenshot, what I would like to do is make the Genre category count how many items under are selected. So let’s say you click “Cinematic”, than Genre would become “Genre 1”.

So yeah, counting already works, just can’t figure out how to place the variable value to this “Genre” text. I was thinking that I should make a text change at the same time with Count +1 event, but I’m not certain how do I assign this change to this Genre button specifically, as it is being outside the Master within another page.

Thanks!



#2

The variable you are using will be available when you use the set text action on a widget. So on the action you have, you’d do something like set the text on the “genre” widget to the word “Genre [[variablename +1]]”


#3

Thanks for your reply. Not sure if I understood you correctly. What I actually end up doing is creating an invisible input field that picks up the global variable value, then using OnTextChange event send the variable value to this “Genre” by doing exactly what you said — “Genre [[variablename +1]]”.


#4

Interesting that you need to “bounce” the variable through the hidden field like that. But if it works, who cares? :slight_smile:


#5

This seems to be my motto using Axure, haha! I guess I couldn’t figure out how to make this Set Text action from the global variable action.


#6

Hi!

Something else that might help you out here since you are dealing with a master is raised events. Events you raise in a master will appear as events in the Interaction pane when you select the master in the page.

This makes super easy to transfer values outside of the master, because you are notified whenever anything is selected/deselected. It also makes your code more organized, since you don’t really have to worry what exactly is going on inside of the master; you just need to respond to its events.

This example raises the (made-up-by-me) events OnGenreSelected whenever any genre is selected, and an OnGenreUnselected whenever any genre is unselected. Here’s what it looks like when you select the master. (This is an Axure 8 screenshot)

Here’s the code for a checkbox in the master. (All checkboxes have identical code.)

image

File: raisedEventCounter.rp (60.4 KB)


#7

Ah, yes I forgot you were using masters! That would explain the inability to set the text inside it with the variable in the way I described. Doh!


closed #8

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