Javascript Button in the top menu not doing anything

I have a TRUE/FALSE variable in my course called Spanish.  On the first slide of the course are two "start" buttons, one to start with English onscreen text, the other to show Spanish onscreen text.  Works fine through the course.

Oddly, some people's system's sometimes randomly switch to Spanish for reasons we haven't uncovered, mostly because for 1000s of people this doesn't happen, just for a random person here and there.  It's weird.  But whatever.

So, I wanted to add two clickable at the top next to the RESOURCES option so the use could click ENGLISH or SPANISH anytime they want/need to.

The only option I see in the in the "actions" that could do this is the EXECUTE JAVASCRIPT option, so that's what I created.

When I publish this course to REVIEW, the buttons are there, they highlight when I hover my mouse over them, but the don't "click", they don't actually do anything.

https://360.articulate.com/review/content/c11c7854-52bf-4566-869b-647cd03fa46f/review

Is there something I'm doing wrong here with the JS trigger?

Is there an easier way to add a toggle switch to the top menu for the Spanish variable? 

7 Replies
Phil Mayor

Have you tried checking the console to see if you get an error.

I think you really need to do:

var spanish = false;
var player = GetPlayer();
player.SetVar (”Spanish”, spanish);

I don't think you can directly set the variable value only via a javascript variable (or at least I have never tried). Booleans are case sensitive so you may need to play around with it.

 

 

 

Jerry Beaucaire

The "among many errors" sounds ominous.   This course was created a couple of years and worked swimmingly, we recently upgraded from SL360 Sept 19 to the most recent version, and yeah, the exact same courses with minimal edits are having tons of issues.

Javascript, which I expected to cause the most issues, has caused pretty much none. I guess we don't really use JQuery stuff.  But the triggers I've used for years attached to audio/media "button click" sounds have all started breaking.

In the past I would use the same small audio "click" file in numerous ways.  If I just wanted an audio "click" on the current screen, I toggled a tick variable to play the TickSound.mp3 on the Master slide.  If I wanted a "click" to the next screen, I'd put another copy of the same TickSound.mp3 on the slide itself, make the button play the click and a media completes trigger would jump to the next slide.  I'd repeat that for PREV button sound.

I only had to set the up once, then could copy to slides as needed ad nauseum.

Most of this doesn't work anymore.  I'm thinking SL is now somehow spotting that all the little mp3s are copies of the same file and connecting them together in a way it didn't used to do.  So my triggers are going off on top of each other and doing crazy things.

I love an upgrade.  :(

Zsolt Olah

Hi, my 2c.

I've seen all kinds of issues with Boolean (depending on browser, OS, version, etc.) when passing back and forth. I always use a number instead.

The only advantage of using True/False vs number (-1,1) is that it takes less memory, which also means execution speed... (unless you're doing complex logical comparisons) But, unless you're building a giant application, it doesn't really matter in Storyline. You can save a lot of headache with browsers, updates, etc. if you use a number variable with -1 and 1 values. (IF you need to toggle, you just multiple the value by -1). 

You can use the numeric value for comparison just like you would with true and false. One advantage of using a variable is if later in the game somehow requirements change and now it's not just T/F or -1,1 but, let's say a third language comes in, you can do it easily with the numbers. With T/F you would need to rethink your design.