Need help making a button appear based on conditional variables

Apr 01, 2014

I’m looking for some variable/trigger help – and possibly a JavaScript solution (not sure). I’ve attached my file as reference.

What I’m trying to accomplish: Make the Continue button on the Review slide (1.9) appear only after a user has viewed all of the objects onscreen. Sounds simple, I know.

The catch: The objects that appear onscreen are dynamic, meaning that 1-6 of them may show up based on a user’s previous choices in the course. (They’re triggered to appear based on variables with certain values.)

What I’ve tried: I can’t simply trigger the Continue button to appear based on visited states, as a user might not actually see all six objects to actually visit them. I tried to set a trigger based on the variable which tracks the six objects (%scene1item%) so that once that variable equals six, the Continue button would appear, only it doesn’t work as anticipated; I think because I have it set to calculate On timeline start, but the slide never reloads, so the calculation doesn’t happen again after a user has clicked objects to review them. Perhaps I’m doing it wrong? And if not, then this is where I’m thinking maybe some sort of JavaScript would run the calculation? I don’t know; I don’t understand JS well enough.

Perhaps the solution is staring me right in the face. I sure hope so! That’s where you come in. I need your help! Many thanks in advance. 

4 Replies
Mike Taylor

Hi Laura! One way you could do that is by using a number variable (ButtonCount) to count how many buttons are displayed. If you add a trigger that subtracts -1 from 6 (the total # of buttons possible) using the same logic you use to hide the buttons you'll have a dynamic count of how many buttons are displayed. 

Then add a trigger to subtract -1 from that ButtonCount number when each button is clicked will let you display your Continue button using the When "Variable change" trigger IF ButtonCount = 0 

That's sort of hard to explain so I've attached an example using your similar logic (I *THINK*)

( Note I haven't added any visited states which would be helpful nor included any safe guards against clicking the same button twice on the review page, etc.  )

Laura Payette

Just following up to say that this worked! Thank you.

It did take a little more tinkering, as I realized that on the Review slide you must trigger feedback/info to show on a layer and NOT on a different slide (as I had my prototype set up to do); the latter sets off the initial slide triggers again when you come back to the Review slide, which makes the math all wonky and then the Continue button doesn't work. Took some head scratching to figure that out, but I finally did. Whew! 

This discussion is closed. You can start a new discussion or contact Articulate Support.