Javascripting Question: Adding a "0" to the front of variable in Storyline 360

Feb 05, 2017

Looking for some help on the following.

I have a dial (SL variable name: DialMin) that is set to show values from 1 - 59 in increments of 1. 

I would like to have the values from 1-9, show up as 01,02,03....09 when I show the variable onscreen using the %DialMin%.

I've pulled some javascript from the forums here but I'm not sure of what I need to do to accomplish my goal. Any help would be appreciated! 

=====

//bring in the DialMin variable from Storyline

var player = GetPlayer();

var numberFromStoryline = player.GetVar("DialMin");

//Convert number from DialMin variable into a string

var convertedToString = numberFromStoryline;

if (convertedToString <10) {

convertedToString ="0" + convertedToString;

}

//set values for Storyline

player.SetVar("DialMin", convertedToString);

Thanks again for the help on this one!

Richard

 

 

 

2 Replies

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