Skip to main content
Skavennwyrm
Participant
September 12, 2018
Answered

Displaying Variables with Decimal places

  • September 12, 2018
  • 1 reply
  • 391 views

Hello,

I have been searching for a solution to this and cannot find one. I am creating a software training and have to load in some variables naturally. I needed some random numbers, so I decided I would initialize all of my variable in JavaScript. Having a programming background I passed a variable OD_SPH as a string from JavaScript to Captivate. Sampled below.

var OD_SPH = "-3.00";

window.cpAPIInterface.setVariableValue("OD_SPH", OD_SPH);

When I attempt to display in captivate it converts this to -3 on display when I need it to show the trailing zeros. I've confirmed that JavaScript is capturing this as a string, but it would seem that captivate is converting this to an integer. Does anyone have any ideas on how to get this to display properly?

Thank you in advance,

Jacob Strand

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer TLCMediaDesign

If this is HTML5 only, just use:

window.OD_SPH = "-3.00";

If you use the cpAPIInterface.setVariableValue, Captivate does run it through a function (cp.ho) to convert a string.

1 reply

TLCMediaDesign
TLCMediaDesignCorrect answer
Inspiring
September 17, 2018

If this is HTML5 only, just use:

window.OD_SPH = "-3.00";

If you use the cpAPIInterface.setVariableValue, Captivate does run it through a function (cp.ho) to convert a string.