Storyline 2 Javascript help

Oct 25, 2017

Hello everyone,

I have a Storyline 2 course with several numeric text entry boxes. I also have some Javascript that adds all the numbers from those boxes and displays a total.

All of the boxes default to "0".

My problem is that when a user backspaces (leaving the box empty), the total displays as NaN. So, I'm trying to write some JavaScript that will change the number for that entry box to "0" if they backspace and leave the box empty.

Here's what I have so far:

var player=GetPlayer();
if (Number.isNaN(player.GetVar("NumericEntry1"))){
player.SetVar("NumericEntry1",0);
}

This doesn't work, but I'm not sure why.

4 Replies

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