Skip to main content
gkeogh
Inspiring
October 5, 2016
Answered

Call an external javascript variable into captivate

  • October 5, 2016
  • 1 reply
  • 1334 views

I need captivate to reference an external JavaScript variable to check if its value is 1 or 0. If the value is "1" I need to display a button, if its "0" the button will be hidden.

The reason I need it external is I would like the customer to be able to change the variable value without having to republish the files.

 

I know if I add a folder and JavaScript file to "Program Files\Adobe\Adobe Captivate 9 x64\HTML\assets" it will always be published every time captivate publishes, the question is how do i get Captivate to reference the variable in this JavaScript file?

 

I'm using the latest version of Captivate 9.0.2, publishing to HTML5

Thanks

Gary

This topic has been closed for replies.
Correct answer gkeogh

Thanks for your suggestions Peter!

I managed to get it working last night using a different method.

First I setup the variable "SP_Assess_Included" in Captivate with a default value of 0.

I then went into the "C:\Program Files\Adobe\Adobe Captivate 9 x64\HTML" folder and modified "index.html"

Then I added the following line in the <script> tag: var SP_Assess_Included = 1;

saved the file and republished the course.

i can now open the index.html or index_scorm.html in my published course folder and my new default variable is there and i can change its value as required and my course reads/updates it correctly on refresh/reload.

Gary

1 reply

Pkoel
Inspiring
October 5, 2016

Hi Gary,

  I am new to Captivate JavaScript as well. I think you would use the window.cpAPIInterface.setVariableValue to set the Captivate variable to the value of the java script variable. Similar to the example code below:

window.cpAPIInterface.setVariableValue("s1tb1",this.name);

where s1tb1 is my captivate variable name and name is my java script variable name.

Peter

gkeogh
gkeoghAuthorCorrect answer
Inspiring
October 6, 2016

Thanks for your suggestions Peter!

I managed to get it working last night using a different method.

First I setup the variable "SP_Assess_Included" in Captivate with a default value of 0.

I then went into the "C:\Program Files\Adobe\Adobe Captivate 9 x64\HTML" folder and modified "index.html"

Then I added the following line in the <script> tag: var SP_Assess_Included = 1;

saved the file and republished the course.

i can now open the index.html or index_scorm.html in my published course folder and my new default variable is there and i can change its value as required and my course reads/updates it correctly on refresh/reload.

Gary