# Convert a Numeric Value to Decimal Format the Articulate Storyline Way

## This blog detailshow to convert a numeric value to decimal format using Articulate Storyline.

Published on Updated on January 30 2020

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 2:

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

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

Step 4:

Add this java code in the JavaScript window.

var player=GetPlayer();

varNumericEntry=player.GetVar(“NumericEntry”);

varNumericEntry=NumericEntry.toFixed(3);

vartxtvalue=NumericEntry.toString();

player.SetVar(“textvalue”, txtvalue);

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 6:

Publish your Storyline file and check the magical output.

how-to-select-right-rapid-authoring-tool-cta