Forum Discussion
Using JavaScript to add the sum of variables in Storyline 360
You can use JavaScript in StoryLine 360 to show the sum of three different variable values. See demo here.
I have also included the SL file so feel free to download and see how it is done! Cheers Gerry.
- SarahHodgeFormer Staff
This is an awesome use of variables, Gerry! I love that you included two options. Thanks so much for sharing the story file!
- AlejandroDeL112Community Member
A great solution for storyline interactives. Thank you
- GerryMcAteer-86Community Member
Glad you found this helpful Alejandro :)
- KerryORourkeCommunity Member
Thank you thank you thank you soooo much for sharing this! I was utterly stuck trying to figure out how to get several variables to add to then show a certain results layer and your .story file and JavaScript saved the day!
- GerryMcAteer-86Community Member
Excellent to hear that you were able to use this Kerry :)
- AbbyMcTeerCommunity Member
Thanks for this Gerry. It really helped me skip the rigorous learning step and copy what you'd done :D.
I did notice that the numeric entry fields seem to inherently save as strings rather than number values when importing into the Javascript code. My solution at the moment is just to have a trigger within Storyline that sets the numeric value in the field to a different variable (that is set to be a number) and then use that in the code.That seemed to work. I wish that the Numeric Entry field in SL would actually keep the value as a number but what can you do?
If anyone else has a more elegant solution that uses Javascript to do it for you.