Change the status of the CheckBox on restart based on LocalStorage
Mar 29, 2024
Hello!
There is a task to make sure that the progress between sessions is saved in localStorage. Specifically, the CheckBox states (Normal/Selected).
1. Using JavaScript, I made it so that when clicking on the CheckBox, information about its status was added to localStorage (true) and to the global variable Storyline (true).
2. When restarting the browser and opening the slide in a new session, JavaScript checks for localStorage, and if there is = true, then the global variable Storyline also sets = true.
3. Next, a trigger is created to change the state to "Selected" if the global variable Storyline = true, but this does not happen.
Please tell me, what could be the matter? As I understand it, it is not provided to change the states when running through pure JavaScript.
P.S. In the example, only the first (red) CheckBox is added
Thanks.
5 Replies
your main problem
here is the fixed script for the start of the slide
https://360.articulate.com/review/content/f47b115f-340e-4ab9-b7dc-00074ebd62b7/review
update: setVar -> SetVar
I knew I had to use GetPlayer(), but I still couldn't figure out how it works. Couldn't find detailed documentation from the developers)
When I click on the "review" link, everything works as it should, but if I download "localStorage-fix.story", open and run locally, then the checkboxes are not saved. The browser console reports errors.
Could this be due to the fact that I have a stripped-down version of Storyline 3? You have more built-in default variables in the source, for example.
strange - no problems on firefox esl, firefox dev, chrome and edge on my side (webserver and file-protokoll)
published with SL 3.86
which version of SL are you using?
in SL 3.84 and newer setVar() and SetVar() seems possible
here is a new version with SetVar()
This option with SetVar() works as it should! And now there is one less warning in the console. Apparently, it really was a newer version.
Thank you so much for your time! I'm sure your find here will be useful to other beginners.