0

If/Then/Else Actions

2491 0 4
Posted   2 years ago

How do I set up an action to evaluate a variable to perform a certain task if the variable is equal to 1 or True (depending on what type of variable I'm using), but have it perform a different action if the variable is not equal to 1 or True (let's say 0 or 2 or False)? I'm not seeing wher I can enter the "else" part of the action. Do I need to enter it as a separate action? If so, does dominKnow read actions in the order they are stacked?

Comments

( 0 )

Answers  ( 4 )

1
Posted   2 years ago

Noticed now, we can add multiple actions to the Button Navigation :) (that's the easiest way! but perhaps these additional scripts will come in handy for other reasons?)

Comments

( 1 )
0
2 years ago     Paul Schneider     753   |   8  

Yes indeed! You can do this for really any trigger.

0
avatar Paul Schneider   |    
Posted   2 years ago

You would set up a 2nd action for the 2nd use case.  In the cases where you want it to fire both actions if a varaible = X, but only fire action 1 if a second condition is also true and likewise for action 2, then you would add that condition to the "conditions" section of each respective action.

Actions would then be something like

If Variable X = 5 Show element(s) ---> This is the main part of the action

AND variable AlternateFactor != 32 ---> this is the condition the AND part is implied.  The part in italics is what you put in the condition. The comparison format used is JavaScript notation.

Comments

( 0 )
1
avatar prabha10   |    
Posted   2 years ago

Sharing another solution we recently discovered if anyone is needing to add multiple destinations to a single button based on a variable...

Instead of the "Navigate to" action on the button, add this line of JavaScript, where hashtags are the Subeo ID* of the destination page:

player.jumpToSubeo(######);

*A pages’s Subeo ID is located in Page Properties.

You can repeat this for each case that you need a different destination. 

Comments

( 0 )
1
avatar prabha10   |    
Posted   2 years ago

Or if you want to use an else statement you could use:

if  (myVariable= "true") {
player.jumpToSubeo(######);
} else {
player.jumpToSubeo(######);
};

 

Comments

( 0 )