Forum Discussion
JavaScript no longer working!
Hi all,
I have been working on my first eLearning course around the ADDRESSING framework. After adding a bunch of interactions today (1.8 & 1.9) my Javascript trigger that was working last night is no longer working! I tried copy and pasting the button into a new course, and works there, so I'm guessing it's something I added today?
I have the same "print" triggers on three slides (1.11, 1.12, 1.17) and none of them are working anymore. Please help!
Thank you so much.
- WaltHamiltonSuper Hero
Did you attach the project in question? I didn't see any JS nor print triggers on slides 1.11 or 1.12, and I didn't see a slide 1.17
- MeganGeeCommunity Member
Hi Walt, thank you - and yes! I thought I had attached the file, but will try again (just in case?). The buttons should be on the last layer of 1.11, 1.12, and 1.17. Please see screenshot of 1.11.
It's possible I'm missing something, so thank you for your patience.
- Jürgen_Schoene_Community Member
is the .story file the current version?
the screenshot don't match to the .story file
- PhilMayorSuper Hero
Have you added any other javascript to your file? Did you look at the console for errors? Depending on where the error is some or all of your code will stop working.
- PhilMayorSuper Hero
Ande after looking at your screenshots and file they are two different things
- PhilMayorSuper Hero
Looking at the slides that do have javascript
1.8 works
1.9 doesn't and throws an error looks like in both you are calling a variable that doesn't exist PrintTitle and some missing semicolons
1.14 Works but again pulls variables not in Storyline
- PhilMayorSuper Hero
If I was being picky I would also add white space around your operators doesn't change the function but helps with readability
- MeganGeeCommunity Member
Thank you so much! I think I confused the files somehow, but now I see the corresponding slides you refer to. Unfortunately, slide 1.8 and 1.14 aren't working for me like they are for you though... to test, I've been publishing to the web and when I click the "print" button, nothing seems to happen. The window doesn't even pop up.
But again, when I copy and paste it into a new story, it works! The window pops up and I can see the questions associated to "exercisenotes." Thanks again for your patience - I'm new to Articulate and am very unfamiliar with JS.
- PhilMayor-b4ca0Community Member
I published each indivdually to make sure there was no JS that was broken elsewhere in the project
The problem is on 1.14 I didn't have time to debug this morning, I pasted it here JSHint, a JavaScript Code Quality Tool
To see if there were any errors, looked like a few, but also noted that the date a nd title variables are not in your project
- MeganGeeCommunity Member
Hi there, after working with the file a little, I seemed to resolve the original issue. I'm not sure what exactly I did, but I'm glad everything seems to be working as designed!
One other thing... when trying to get the course to pull the current date/time, as well as adding a heading to each notes printout... I get "null." Can someone help me identify how to resolve these things? I don't want to mess with any of the code in fear of messing up what has already been resolved. File attached.
Thank you!
- NedimCommunity Member
As Phil pointed out, you don't have variables "SystemDate" and "PrintTitle" declared in Storyline. Also, in your JavaScript code, you say " var exercisenotes1=player.GetVar("csreflect1");" but on your layer with text fields, you refer to "csareflect1" (same issue with all 4 text variables). It appears that you have declared similar variables for the same purpose and mismatched them.
Solution:
1. Create a blank text variable "SystemDate"
2. Create a text variable "PrintTitle" (I'm not sure what is the value you want to assign to this variable)
3. Slide 1.12: replace cs with csa in cs variables in JavaScript code on the Reflection Print layer
If you publish only slide 1.12 for testing purposes, the "SystemDate" will not show unless you place the Execute JavaScript trigger from the first slide (one that sets up the date) to Slide 1.12. Or you may place it on the Master slide to make sure it's always running.