Javascript to print and email notes

Hello,

I am trying to implement Stephanie's javascript method for the learner to be able to print and send his/her notes by email, but I am having some difficulties.

Basically, the print option alone works well, but once I try to add a trigger for the email button, none of them work. It seems to interfere at some level. And I didn't manage to have the email trigger work alone. 

I am really not a coding expert (like many of us!), but if someone could help I would be most grateful!!

I am attaching two files:

- javascript_print_OK : the print javascript executes well 

- javascript_print_notOK : I added the javascript for email, but neither the print nor the email javascript execute.

Thank you !!

Bastien

15 Replies
Curtis Kynerd

I too am trying to create a version of what Stephanie did with creating a way for the learner to email feedback to the instructor.  I have a variable called Feedback created in Storyline.  Below is my JavaScript:  I cannot get the variable to populate the body of the email.  I am not fluent in JavaScript.  Can anyone show me where the script is failing?

var player = GetPlayer();
var bodytxt=player.GetVar(“Feedback”);
var mailto_link=’mailto:’+curtis.kynerd@nissan-usa.com+’&body='+bodytxt+"%0d%0A";
win=window.open(mail_link,’emailWin’);

 

Curtis Kynerd

Joanne, thanks for your help.  I appreciate that since I am certainly no JavaScript expert.  However, I am still unable to populate the body of the email with my Feedback.  Is there something else that I am missing here?  I am sure it is something simple, but I just can't seem to find the culprit at this point.  Any help is greatly appreciated.  If the JavaScript is correct, then I must be in error somewhere else.  My Storyline variable, Feedback is populating the text field as it is supposed to do, it is just not showing up in the body of the email. 

Joanne Chen

Hi Curtis, I took a look at your story file and there are some problems in your JS code.

  1. You must have correct variable name in JS code. For example: your variable called "email" but you told JS code to execute "emailaddress". And JS can't find "emailaddress" so it fails.
  2. The symbols " and “ means different to a code. You have to use the symbol " in a code. (JS can recognize "Mes Actions" but not "Mes Actions“)

I also attached your story file with my modification as above.

Joanne Chen
Joanne Chen

I took a look at your story file and there are some problems in your JS code.

  1. You must have correct variable name in JS code. For example: your variable called "email" but you told JS code to execute "emailaddress". And JS can't find "emailaddress" so it fails.
  2. The symbols " and “ means different to a code. You have to use the symbol " in a code. (JS can recognize "Mes Actions" but not "Mes Actions“)

I also attached your story file with my modification as above.

Hi Bastien, this is for your file. Hope this helps.

Joanne Chen

Hi Curtis, you don't need a new layer for email nor a submit button for feedback.  Also you don't need a trigger to jump to URL/file. There were too much trigger and code and that will only confuse the system. Take them out and it should run smoothly as you want.

I've attched your file with my modification(first slide). And I found you have two vaiables for mail address and subject so I add another slide with additional JS code in it for you to use those two variables. I will suggest use variables for them in case you might need to change them in the future version.

Let me know if you need more help.

Curtis Kynerd

Joanne,  sorry to have to ask for you help again.  I have several courses with the same feedback slide at the end.  In testing them this morning, I cannot get them to work.  When I go to your example it works perfectly.  When I try to copy or import your example, I do not get the same success.  I cannot for the life of me figure out why it is not working.  Does something change when you import the slide to another .story file?  This is frustrating.  I know I am missing something that is probably very simple, but I just don't see it.

Aaron Kapala

This is great, my only question would be:

How would the Javascript code need to be amended if you want to keep the format of the text that the learner has written?

For example if they write the following:

'This information is very useful.

It would be great to learn more.'

It ends up printing like this:

'This information is very useful. It would be great to learn more.'

I know this is an old forum but as I was using this example it made sense to comment here rather than create a new question.

Thanks, Aaron

 

Logan Stahler

Hi all-

Looking for a bit of help.  I want to let learners print notes that they took throughout the course via one lightbox slide.  I only need the one text entry variable to be captured and printed.  When I try the print JS from the above source file, I get an empty pop-up window in Chrome.  Thoughts?  Help?

Thanks!

Logan

Brian E.W. McNulty

The question from Aaron Kapala above:

"This is great, my only question would be:

How would the Javascript code need to be amended if you want to keep the format of the text that the learner has written?

For example, if they write the following:

'This information is very useful.

It would be great to learn more.'

It ends up printing like this:

'This information is very useful. It would be great to learn more.'

I know this is an old forum but as I was using this example it made sense to comment here rather than create a new question.

Thanks, Aaron"

 

Does anyone have a solution to this? I am having the same problem. Thanks!