Storyline 360 - Javascript question based on a Stephanie Harnett activity

Aug 09, 2017

Hi, folks,

I'm hoping there is someone out there who can look at my Storyline file and see what I've done wrong. I used some code to create a printable page based on this tutorial from Stephanie Harnett:

https://community.articulate.com/discussions/building-better-courses/user-notes-that-they-can-print-and-email

I've compared my code to hers, and made sure I had all of my variables within Storyline and defined in the code, and simply cannot discover what I've done wrong. When I publish her file, it works. When I publish mine, it does not. I'm sure it is something simple that I just can't see. I even gave it a night's rest and came back to it fresh this morning and still can't find what's wrong. I need someone with more javascript experience than I have to review this to see if they can find it.

I only used the print button part of her tutorial. I originally had the email working, but then it, too, quit, and I hadn't changed the code, so it must have been within the naming of the Storyline elements themselves. I decided I didn't need the email function. I also left out the date.

Thank you, in advance to whoever may have a bit of time to look this over for me.

Arleen

8 Replies
Trina Rimmer

Hi Arleen. I've been playing around with your file all morning. I did a series of tests by adding some periodic alert js code to your code and then publishing, uploading, and testing. I found that it runs fine up to the point of the pop-up window and then fails when it gets to the text variables. I'm sorry I haven't been able to further narrow it down. Unfortunately, my javascript skills are somewhat immature so it's possible there's a very simple syntax error that's causing it to fail and I'm just not seeing it. For instance, I noted that you had spaces in the variable names "1 have" and "1 need" in Storyline, but the js references those as "1have" and "1need." Simple things like that are a likely cause of failure, but I haven't had any luck in sniffing it out further. 

I would suggest posting your help request and the project file link in Stephanie's original thread since a lot of our community javascript experts are subscribed to it and seem to be actively helping others. I'm sorry I couldn't get it sorted for you. Hopefully a much savvier javascript person will jump in and solve the case!

Tristan Hunt

Hi Arleen,

I copied your javascript into notepad++ and the first thing I noticed is some of your quotation marks aren't actually quotation marks but some other character. This will cause the javascript to fail but is easily fixed with a global find and replace.

The next thing is the 1need etc showed as possible errors. Javascript shouldn't have a problem with variables like this but some web browsers may do so to be safe I flipped them around.

This made it work but your html had the variables showing as text rather than a variable as you hadn't put quotation marks around them.

Attached is the updated JavaScript.

You will still need to edit the formatting of the HTML as it removes the spaces. You could look to use a table for formatting.

 

 

 

Zsolt Olah

First, as Tristan said, replace all the funky quotation marks with simple ". 

Second, you can't have JavaScript variables starting with a number.

var 1have=

Is not valid. You must start with either _ or a letter. 

Third, when you want to use this variable in a context like: 

contents+="<div style='font-size:16px;font-weight:bold;margin-top:10px;'>1. Professionalism/Work Ethic Have: +1have+ Need: +1need+</div>";

It won't work because the variable is inside the text. You need to do something like:

contents+="<div style='font-size:16px;font-weight:bold;margin-top:10px;'>1. Professionalism/Work Ethic Have:"+1have+" Need:"+1need+"</div>";

Closing the double quotes and reopening after the variable. But again, 1need is not valid, you should start all of them with a letter like v1need or something.

Zsolt 

This discussion is closed. You can start a new discussion or contact Articulate Support.