Forum Discussion
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 the code.
Thanks,
Gerry
- StefanGottfr790Community Member
Hi Gerry, what kind of formatting would you like to achieve? I assume the users can't format (bold, latin, ...) their notes in the journal themselves. So how should JavaScript know what to format?
- GerryBabuin-b0bCommunity Member
Hi Stefan
There are three sections and three headers in the final slide and when I go to email the content they are all the normal body text. I would like to have the headers be larger and maybe add some space for clarity.
- StefanGottfr790Community Member
Maybe if I could see your code, I can try to insert some empty lines for clarity. But I don't know how to make the font larger.
- GerryBabuin-b0bCommunity 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');- StefanGottfr790Community 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;
- GerryBabuin-b0bCommunity Member
Thanks Stefan
That didn't really work for me. You did help me figure out a solution to the spacing issue. I am just trying to get the header bolder or larger. Thanks for your help!
- StefanGottfr790Community Member
Interesting, but good if it helped. I am following for a solution to make text in an e-mail bold with javascript.