Forum Discussion
GerryBabuin-b0b
3 years agoCommunity Member
Formatting text entry gathered for email body
I have set up a journal that at the end of the course the user can email to themselves. Is there any way in the javascript to add some formatting? I have tried a couple of things but it just breaks ...
GerryBabuin-b0b
3 years agoCommunity Member
Thanks Stefan
Here is the code:
var player = GetPlayer();
var email = 'Email';
var ans1 = player.GetVar('TextEntry_Intro');
var ans2 = player.GetVar('TextEntry_GrandIllusions');
var ans3 = player.GetVar('TextEntry_Master');
var subject = 'My Happiness Journal';
var emailBody = 'Be Happy Journaling' + '\n' + 'Introduction Journaling: ' + ans1 + '\n\n' + 'Grand Illusion Journaling: ' + ans2 + '\n\n' + 'Master Journaling: ' + ans3;
var mailto_link = 'mailto:' + email + '?subject=' + subject + '&body=' + encodeURIComponent(emailBody);
win = window.open(mailto_link, 'emailWin');
- StefanGottfr7903 years agoCommunity Member
I tried to alter your code a bit it gets the empty lines done in my test-file:
var player = GetPlayer();var email = 'Email';var ans1 = player.GetVar('TextEntry_Intro');var ans2 = player.GetVar('TextEntry_GrandIllusions');var ans3 = player.GetVar('TextEntry_Master');var subject = 'My Happiness Journal';var emailBody = 'Be Happy Journaling' + '%0A' + '%0A' +'Introduction Journaling: ' + ans1 + '%0A' + '%0A' + 'Grand Illusion Journaling: ' + ans2 + '%0A' + '%0A' + 'Master Journaling: ' + ans3;var mailto_link = `mailto:${email}?subject=${subject}&body=${emailBody}`;window.location.href = mailto_link;