Highlighted

Displaying Variables with Decimal places

New Here ,
Sep 12, 2018

Copy link to clipboard

Copied

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

Adobe Community Professional
Correct answer by TLCMediaDesign | Adobe Community Professional

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.

TOPICS
Advanced

Views

160

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Displaying Variables with Decimal places

New Here ,
Sep 12, 2018

Copy link to clipboard

Copied

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

Adobe Community Professional
Correct answer by TLCMediaDesign | Adobe Community Professional

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.

TOPICS
Advanced

Views

161

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 12, 2018 0
Adobe Community Professional ,
Sep 17, 2018

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 17, 2018 1