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

Accessing variables created in JS

Explorer ,
Dec 26, 2017 Dec 26, 2017

Hi,

I have 2 questions:

1. How I could access a variable assigned via a Text Entry Box by a user in a JS script? For example a user fills in an entry box (and therefore assigning a variable accessible in the Captivate interface by $$v_my_variable$$), and I would like to access the value within a js window to do some JS calculations on it.

2. How do I do the opposite. I generate some values within a js (eg. generating a random number and assigning it to a variable, eg:

var number = alert(Math.random());

How do I access $$number$$ from a text box or a smart shape in Captivate?

Thank you

366
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

correct answers 1 Correct answer

Advisor , Dec 26, 2017 Dec 26, 2017

I have been successful at manipulating variables with javascript by simply using

window.variableName

For example, I have a variable called points. The value of this variable is created by concatenating two other variables - red and black.

The javascript looks like this:

window.points=String(window.black).concat(red);

Perhaps this example may be useful in advancing your project.

Translate
Community Expert ,
Dec 26, 2017 Dec 26, 2017

I am not a JS expert, but maybe these articles I wrote for newbies like myself, does explain how to exchange variables using JS. I did use TEB's:

Playing with Numbers - part 1 - Captivate blog

Playing with Numbers - part 2 - Captivate blog

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
Explorer ,
Dec 26, 2017 Dec 26, 2017

Thanks - I found what I needed in the posts that you linked.

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
Advisor ,
Dec 26, 2017 Dec 26, 2017

I have been successful at manipulating variables with javascript by simply using

window.variableName

For example, I have a variable called points. The value of this variable is created by concatenating two other variables - red and black.

The javascript looks like this:

window.points=String(window.black).concat(red);

Perhaps this example may be useful in advancing your project.

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
Explorer ,
Dec 26, 2017 Dec 26, 2017
LATEST

Thanks. That's even more informative points.

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