Forum Discussion

GerryMcAteer-86's avatar
GerryMcAteer-86
Community Member
4 years ago

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.

  • This is an awesome use of variables, Gerry! I love that you included two options. Thanks so much for sharing the story file! 

  • KerryORourke's avatar
    KerryORourke
    Community 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! 

  • AbbyMcTeer's avatar
    AbbyMcTeer
    Community 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.