Javascript and email

Hi - I am trying to set up javascript to grab the students name and email it to me once they click on submit. I've looked around and found this but can't seem to get it to work. I checked the variable names to make sure they match but I get nothing when I click "submit" - Any help would be a life saver to me! thanks!

var player = GetPlayer();
var email = EM;
var fn = player.GetVar('FirstName');
var ln = player.GetVar('LastName');
var subject = 'FF Mod 1';
var emailBody = 'Student '+fn+'. '+ln+';

var mailto_link = 'mailto:' +email+ '?subject=' +subject+'&body=' +encodeURIComponent(emailBody);

win = window.open(mailto_link,'emailWin');

2 Replies
Rubie Buenaobra

Hi Courtney,

Can you try to use this and see if this works? I have found this in Java Best Practices Examples

var player = GetPlayer();

var fn = player.GetVar('FirstName');

var ln = player.GetVar('LastName');

var email="yourAddress@email.com";
var subject="FF Mod 1";
var body_start="Student " +fn+ " " +ln+ "\n";
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start;
win=window.open(mailto_link,'emailWin');

Hope this helps.