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

Hide multiple elements via javascript or actions in case of different variable values - how?

Community Beginner ,
Oct 26, 2015 Oct 26, 2015

Note: I'm still in Captivate 8

The Question has 2 Parts:

(1) Is there a possibility to hide (or show) elements via javascript instead of advanced actions? I think this would be a much faster workflow. I'm thinking at something like

if variable1 <= 100 screenx.elemeta.hide;

if variable1 <= 90 screenx.elemetb.hide;

if variable1 <= 80 screenx.elemetc.hide;

if variable1 <= 70 screenx.elemetd.hide;

(2) If this is not possible ... OK, than I use advanced actions. But there is the 2nd Problem: It only runs the first part of it when exporting in HTML5.

See Picture. I try to hide - or hide not - 9 Elements in case of different Values in a Variable. Lets say the value is "7". In se9 it is aked if the value is lower or equal 9 for hiding element ausw_se_10. This works. In se8 it is asket if the value is is lower or equal 8 for hiding element ausw_se_09 - what you see in the picture. This and the following hides does not work. Am I doing something wrong or is this a bug? And is there a solution?

sc_2015_10_16_erweiterte_aktionen.jpg

877
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

People's Champ , Oct 26, 2015 Oct 26, 2015

Showing and hiding is a relatively easy command if using HTML5:

cp.hide("element_name");

If you wanted to hide as many as you are describing, you would need a very stringent naming convention and use a loop to hide the elements.

Translate
Community Beginner ,
Oct 26, 2015 Oct 26, 2015

Forget Part 2 above ... it works now. Don't know exactely why, perhaps just a fault of myself ... Sorry for thinking about a bug ...

Part 1 - how to use Javascript for that - is still interesting.

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 ,
Oct 26, 2015 Oct 26, 2015

Showing and hiding is a relatively easy command if using HTML5:

cp.hide("element_name");

If you wanted to hide as many as you are describing, you would need a very stringent naming convention and use a loop to hide the elements.

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 Beginner ,
Oct 27, 2015 Oct 27, 2015

Hiding multiple elements via javascript-code in captivate this way works fine. Thank you.

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 ,
Oct 27, 2015 Oct 27, 2015

I see a potential problem with the logic as you have it presented in the question.

If you have a value in variable1 that is less than 70, the FIRST condition of less than 100 will be met and NO OTHER test will trigger.

So, although it will not fail, it will not operate correctly.

You need to ensure via the logic that you are testing for the smallest condition possible <= 70, then move to <= 80, then <= 90, <= 100, and ADD a final test of >100 as an error check.

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 ,
Oct 27, 2015 Oct 27, 2015

It would actually need to be:

if variable1 > 90 && variable1 <= 100 screenx.elemeta.hide;

else if variable1 > 80 && variable1 <= 90 screenx.elemetb.hide;

else if variable1 > 70 && variable1<= 80 screenx.elemetc.hide;

else if variable1 <= 70 screenx.elemetd.hide;

or you could use a switch statement.

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 Beginner ,
Oct 27, 2015 Oct 27, 2015
LATEST

First: Thank you all. But ...

@BDuckWorks: Why should there no other test trigger?

@TLCMediaDesign: That's a solution for another question, for my example it's not not neccessary or even wrong.
Let me explain a little bit more in detail: There are 10 Elements on the screen, if x>100 all will stay,

from 91 to 100 only one element - lets say #10 - will be hidden.

from 81 to 90 a second element - lets say #9 - will also be hidden.

...

from 1 to 10 a 10th element - let's say #1 will also be hidden. Then the are none left.

if variable1 <= 100 screenx.elemeta.hide;

if variable1 <= 90 screenx.elemetb.hide;

if variable1 <= 80 screenx.elemetc.hide;

...

works fine.


In your example (... else if ...) there will be only one element hidden at the end. Feel free to discuss further, for my example it's solved at this point. And again: Thanks you!

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