Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Captivate 7: get and set variables only for javascript html5 output… HELP!

New Here ,
Jun 08, 2014 Jun 08, 2014

Unfortunately it looks like that the only resource (a pay one) in the whole www to know the necessary code to get the values from captivate's variables and set variables' values back through javascript commands for HTML5 output (only interest) is the "JavaScript Video Series for Adobe Captivate 7" from CaptivateDev.com… which, I can't afford…  I've basic knowleg in js, and please I'd like a little help with that, OR just fix the following syntax please, I'm stuck with this project cuz doesn't want to run in html5:

I've the following variables in captivate

Associated with TEBs:

     PROM

     AABS

     ABIO

     AQUIM

     AVERB

     SBIO

     SQUIM

     SVERB

Associated with a text labels ($$variable$$):

     vIIA

     vIA

And I need to calculate the following operations in javascript:

var IIA = ((((AABS*3)+((ABIO*3)-(25-SBIO-ABIO))+((AQUIM*3)-(25-SQUIM-AQUIM))+((AVERB*3)-(25-SVERB-AVERB)))*20)/300)

var IA = ((((PROM*(4*(PROM-10)))+(IIA*(100-(4*(PROM-10))))))/100)

     (Imagine doing that with the advance action assistant)

Finally these operations display in text labels which are: $$vIIA$$ and $$vIA$$

     …Thanks in advance

TOPICS
Advanced
2.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 09, 2014 Jun 09, 2014

Where is your JS syntax? And it is perfectly possible with Advanced actions, maybe seems cumbersome but since you don't want to spend money on Jim's very valuable course.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 09, 2014 Jun 09, 2014

I tried to be clear, I didn't say "I don't want to spend money" I just said "I can't afford it" I would've done is were possible in this moment, but anyways it's sad there is not any free tutorial about… I didn't post the sintax because i've trying in many differents ways and none result, so I thought it was better to expose the problem in this forum without having the wrong sintax crowding the post.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 09, 2014 Jun 09, 2014

You'll need to get the variable values with:

cp.vm.getVariableValue(varName);

You can also access them in the window object:

window.varName

Then set the value with:

cp.vm.setVariableValue('varName', varValue);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 09, 2014 Jun 09, 2014

I'm missing something in the script (that execute a button), there is my code:

var calc = function (){

     var PROM = cp.vm.getVariableValue(uProm);

     var AABS = cp.vm.getVariableValue(uAabs);

     var ABIO = cp.vm.getVariableValue(uAbio);

     var AQUIM = cp.vm.getVariableValue(uAquim);

     var AVERB = cp.vm.getVariableValue(uAverb);

     var SBIO = cp.vm.getVariableValue(uSbio);

     var SQUIM = cp.vm.getVariableValue(uSquim);

     var SVERB = cp.vm.getVariableValue(uSverb);

     var IIA = ((((AABS*3)+((ABIO*3)-(25-SBIO-ABIO))+((AQUIM*3)-(25-SQUIM-AQUIM))+((AVERB*3)-(25-SVERB-AVERB)))*20)/300);

     var IA = ((((PROM*(4*(PROM-10)))+(IIA*(100-(4*(PROM-10))))))/100);

     cp.vm.setVariableValue('IIA', vIIA.toFixed(3));

     cp.vm.setVariableValue('IA', vIA.toFixed(3));

};

calc();

The labels $$vIIA$$ and $$vIA$$ don't display the value yet ¿what I've missed here? …by the way the variables associated with TEBs are those who have the prefix "u" and not those I commented in first place (uppercase variables)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 10, 2014 Jun 10, 2014


In the lines that do the calculations the variables should be:

var vIIA and var vIA

You are setting the value of IIA and IA to a variable that has never been defined, as in:

cp.vm.setVariableValue('IIA', vIIA.toFixed(3));

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 11, 2014 Jun 11, 2014

The variables vIA and vIIA has been defined in the project variables, and the 2 text labels display them $$vIA$$ and $$vIIA$$ so if I set the sintax as you told me, it will have not any sense the parameters of the last two lines:

var vIIA = ((((AABS*3)+((ABIO*3)-(25-SBIO-ABIO))+((AQUIM*3)-(25-SQUIM-AQUIM))+((AVERB*3)-(25-SVERB-AVERB)))*20)/300);

var vIA = ((((PROM*(4*(PROM-10)))+(IIA*(100-(4*(PROM-10))))))/100);

cp.vm.setVariableValue('vIIA', vIIA.toFixed(3));

cp.vm.setVariableValue('vIA', vIA.toFixed(3));

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 11, 2014 Jun 11, 2014

The syntax is setVariableValue(cpVariable, value)

you were trying to set the value using an undefined variable.

Do not change the Captivate variable, it should be:

cp.vm.setVariableValue('IIA', vIIA.toFixed(3));

cp.vm.setVariableValue('IA', vIA.toFixed(3));

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 25, 2016 Nov 25, 2016

Thanks for the previous posts but I still can't figure this sh*t out.

I have:

  • a variable named "text" with value hello.
  • 1 slide with a textbox with variable $$text$$ in it
  • Javascript: cp.vm.setVariableValue('text', 'bye');

And nothing happens.

Test 2:

I have:

  • a variable named "text" with value hello.
  • 1 slide with a textbox with variable $$text$$ in it
  • Javascript: var test = cp.vm.getVariableValue(text); alert(test);

And it alerts an empty alert box

Thanks in advance!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 27, 2016 Nov 27, 2016

What version of Captivate and what type of output, swf or HTML5 or both?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 27, 2016 Nov 27, 2016

Hi thanks for the fast response,

I use Captivate 7 and HTML5

and i use the browser preview.

Sorry for not specifying.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 28, 2016 Nov 28, 2016

Just use:

window.yourVaraibleName = "someValue";

In html5 all of the variables are in the window object

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 28, 2016 Nov 28, 2016

Thank you so much for explaining this, thought I would never get this to work!!!!!

Is there a way I can do something like this:

var number = window.YourVaraibleName;

number + 5;

I tryd to add:

ParseInt(number);

But no result

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 28, 2016 Nov 28, 2016
LATEST

Sorry I'm a javascript noob

It's:

number = number + 5;

Thanks for the help!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources