Javascript to print and email notes
Jan 25, 2016
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
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’);
Hi Curtis, you've missed minor things, please try below
var player = GetPlayer();
var bodytxt=player.GetVar("Feedback");
var mailto_link='mailto:'+"curtis.kynerd@nissan-usa.com"+'&body='+bodytxt+"%0d%0A";
win=window.open(mailto_link,'emailWin');
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.
Hi Curtis, I took a look at your story file and there are some problems in your JS code.
I also attached your story file with my modification as above.
Hi Curtis, sorry, the content of repliment above should be for Bastien's file. and if you can share your stroy file, it will be easier for someone to give you feedback or find out what's wrong in your case.
This post was removed by the author
Hi Bastien, this is for your file. Hope this helps.
Joanne, Thanks for your feedback. Here is my story file. I know it must be something simple that I am overlooking. I really appreciate your help on this.
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.
Joanne, thank you so much for your help. I have it working properly now. I appreciate you taking the time to assist me. This makes a huge difference that I will be incorporating into several courses over the next several weeks.
Curtis, good to hear, I am glad to be helpful.
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.
Hi Curtis, it won't change anything when importing slides. I guess it might due to the name of variables. If you have different variable name from what I wrote in JS code it won't be triggered successfully. Make sure you have exactly the same name(case sensitive) in both JS code and variables
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
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
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!