Javascript help
Jul 05, 2019
Hello, I've been working up a 50 question assessment and need the content of text boxes to fill an email. I've managed to get this working for the first question but need to figure out the JavaScript for the remaining question responses.
Ive set it up so that the feedback box (var fbk = player.GetVar('Question1');)displays the first answer in the email, how would I go about populating multiple questions to form multiple lines within the email please?
This is my script so far:
var player = GetPlayer();
var email = 'your_email@address.com';
var fbk = player.GetVar('Question1');
var subject = 'Course Feedback';
var emailBody = 'Here is some feedback:' + '\n' + fbk;
var mailto_link = 'mailto:' + email + '?subject=' + subject + '&body=' + encodeURIComponent(emailBody);
win = window.open(mailto_link, 'emailWin');
Any advice greatly appreciated :-)
Regards,
John.
6 Replies
How much text do you think you will get? There is a character limit for mailto:
Also users will be able toe dit the text in the email. It may be easier to save it all to a PDF using pdfMake and get them to email that to you.
Hi Phil, it’ll be at least 1000 characters per mail.
pdfMake sounds promising, do you have any instructions available please?
Regards, john.
The limit is about 2000 characters (varies by browser)
This is a post that describes using pdfMake https://community.articulate.com/discussions/articulate-storyline/storyline-360-generating-a-pdf-certificate-using-javascript
Using the documentation you can do pretty much anything. I would use defined pagebreaks otherwise it can get messy. ideally you test it online, if it is your first time building I would test incrementally this way you know when it works and when it stopped working. Also use a "proper" text editor like atom as that will capture most syntax errors.
This is one that I built as a certificate https://360.articulate.com/review/content/83005bc5-497c-4ec6-9fcb-16b51c4ad2b2/review
I have also built a huge document that acted as a learning journal, the options are pretty much unlimited.
Perfect! Thankyou I will take a look :-)
I really like this layout and template - it would be great if you could share this please ? :-)
This discussion is closed. You can start a new discussion or contact Articulate Support.