Skip to content

Convert a Numeric Value to Decimal Format the Articulate Storyline Way

Have you ever faced a challenge trying to convert a numeric value to decimal format in Articulate Storyline? Well, I certainly have. After a lot of tries, I succeeded using JavaScript. Want to know my success secret? Take a look at the steps.

Step 1:

Take a numeric data entry field. By default, a numeric variable named “NumericEntry” is created.

Step 1

Step 2:

Create a text variable named “textvalue” and set the default value as empty.

Step 2

Step 3:
Now insert a button named “Convert” and assign a trigger “Execute JavaScript” when user clicks the button”.

Step 3

Step 4:

Add this java code in the JavaScript window.

var player=GetPlayer();




player.SetVar(“textvalue”, txtvalue);

Step 4

Let’s now look at the purpose of each line of code.

var player=GetPlayer(); is for extracting the properties of the Player.

varNumericEntry=player.GetVar(“NumericEntry”); is for passing the user entered value to the JavaScript function.

varNumericEntry=NumericEntry.toFixed(3); is for fixing the decimal points. Here I’ve taken 3 decimal points.

vartxtvalue=NumericEntry.toString(); is for converting the numeric value to a string format.

player.SetVar(“textvalue”, txtvalue); is for passing the variable to Storyline.

Step 5:

Now display the value of the text variable (“textvalue”) by placing the text “textvalue” between two “%” symbols.

Step 5

Step 6:

Publish your Storyline file and check the magical output.

Authoring Tool Finder - Find the Best Suited Authoring Tool for Your Needs