Forum Discussion
Only display variables with certain values (SL360)
Happy Friday everyone!
I'm trying to figure out the best way to display only variables that have a certain value (in this case "True").
On slide 01 (attached) I want the users to select items that they want to remove, and then on slide 02 explain why they selected each item for removal. So if they select items 1, 4, 7, and 10 for removal, I only want those items to appear on slide 02 with TEBs for the explanation for each.
I know that I can show/hide objects based on the values of the variables, but how to I control the formatting for the slide to look ok? I would have to include a layout that includes all 10 options, but it would look really weird if I only showed the objects associated with 1, 4, 7, and 10.
Any suggestions will be greatly appreciated.
Thanks!
- WaltHamiltonSuper Hero
When I've done that, I used different variables on the second page. The I ran a JS to sort the chosen objects and put them in those variables, showing only the non blank ones.
- ChristopherD273Community Member
Hi Walt,
Thank you for the response. Could you provide a little more information? I'm not sure how having different variable would solve this issue. I would still need to reference those variables in the layout of the second slide. If I have a reference to variable 01 in the top left corner and a reference to variable 10 in the bottom right and the learner only selects those two, how to I display variable 10 in the second position instead of the 10th?
- ChristopherD273Community Member
Just a little more context:
I'm working on an activity about polypharmacy and deprescribing. The patient has a list of 12 meds that she is currently taking. The learners have to determine which ones they would recommend deprescribing and then on the next slide explain why for each med.
- SteveGannonCommunity Member
Hi Christopher,
Attached is a rough demo.
On the second slide, the first set of triggers determines how many buttons were selected on the previous slide. The next 10 triggers remove a mask over each row of two boxes (to simulate the number of rows needed in the table). Then, custom variables are used to hold the name of each button. Finally, some JavaScript is used to get just the names of the buttons selected.
The JavaScript could be much more efficient by using If...then structures within a Repeat loop. I kept it simple (albeit with many more lines of code) for clarity.
You'll need to add remaining text entries since up to 10 buttons can be selected. Also, this is rough so you'll want to clean it up, add some error checking, etc. However, if you study the triggers and the JavaScript trigger, I think you'll be able to follow what's happening.
Since this uses JavaScript, remember to publish to test this; you can't view it in Preview mode.
- ChristopherD273Community Member
Thanks Steve! I'll play around with this example.