Forum Discussion
Reset multiple variables to default values
Is there any shortcut for reseting many variable to their default values? I'm creating a scenario based training in which I have about 20 variables tracking user progress. If they choose to restart the training I need to reset all of the variables. Can that be done with a single trigger or javascript versus adding 20 individual triggers to my Restart button? Thank you!
39 Replies
- staceykramer2Community Member
Hi,
I have about 25 variables that I would like to reset with the click of a reset button. All of these items are on a single slide with layers. I added a trigger to the reset button using the javascript above but it is not resetting the variables. Is there another step that I might be missing?
Should this code reset the variables on the slide if the reset button is on the same slide? Does the reset button need to be on a different slide in order for the timeline to reset first?
Does my code look correct or am I missing something?
var player = GetPlayer();
player.SetVar("greenbeans", "False");
player.SetVar("saladmix", "False");
player.SetVar("mixedveggies", "False");
player.SetVar("slicedtomatoes", "False");
player.SetVar("topsirloin", "False");
player.SetVar("yogurt", "False");
player.SetVar("grilledsalmon", "False");
player.SetVar("milk", "False");
player.SetVar("mixedfruit", "False");
player.SetVar("pasta", "False");
player.SetVar("pudding", "False");
player.SetVar("quinoa", "False");
player.SetVar("apple", "False");
player.SetVar("beans", "False");
player.SetVar("slicedapples", "False");
player.SetVar("blueberries", "False");
player.SetVar("bread", "False");
player.SetVar("brownrice", "False");
player.SetVar("cherries", "False");
player.SetVar("cottagecheese", "False");
player.SetVar("greenbeans", "False");
player.SetVar("grilledchicken", "False");I greatly appreciate any input.
Thanks!
Stacey
- SteveGannonCommunity Member
Stacey: Based on your description and code, this should work. All of the variables you have listed are defined in Storyline, spelled exactly that way (all lowercase), and are True/False variables (not number or text), correct? If so, have you tried publishing your file and placing the published output on a web server? Sometimes, JavaScript won't run when the published output is launched from the local drive.
Uday: I apologize for the late reply; I'm just seeing your note now. I no longer have IE 7 on any of my machines so I can't say whether your JavaScript should run in that environment. When trying it out, be sure you're testing the content from a server and be sure JavaScript is activated in the browser (sometimes a user's security settings are set quite restrictive and may block JavaScript).
- staceykramer2Community Member
Thank you, Steve. I have not tried publishing to a server yet. That might be the key.
Hi Stacey,
If you're in need of a testing web server, you may want to look at one of the free options mentioned in this article.
- Emma-LeeYarwoodCommunity Member
Hi
Does anyone know if the restart trigger problem has been resolved in Storyline 2? I need to make a case to our IT department to get the upgrade prioritised.
Thanks
Emma-Lee
HI Emma-Lee,
It looks like the restart course trigger is working as expected in Storyline 2.
- JonathonMillerCommunity Member
This looks like it is all for true/false variables. Will the javascript method work for variables with a number value?
- AndreaSeatonCommunity Member
This worked for me too. What a life saver!
Awesome happy to hear that this helped you out Andrea!
- SheetalRainaCommunity Member
Hello Chris,
I am beginner and not having much knowledge, I have four button on the slide in which i had to keep 3 visible first and the 4 hidden, when all the 3 are visited then 4 button should be shown can you helpme to sort out this
Related Content
- 12 months ago
- 12 months ago
- 12 months ago
- 12 months ago