JavaScript

Hi everyone - I am trying to test a little bit of JavaScript. Basically, I have text field, which I have renamed "Name" and a button with a trigger to execute JS... 

I want the person's Name to end up in the subject line of the email that sends when the button is clicked. Something is up with the bit of code at the end of line 2 below.

Without +player.GetVar("Name"), the email sends OK but as soon as I add that little bit to the end, it does nothing at all... 

Also, my variables table doesn't show Name as being used in any other instance, so I'm assuming it simply can't find it - definitely spelt the same way etc.

Here's the full script:

var email="test@myemail.com.au";
var subject="subject line"+player.GetVar("Name")
var body_start="This is the start of the body.";
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start;
win=window.open(mailto_link,'emailWin');

 I've also added the Storyline file if you want to take a closer look at what I've done with the text entry field.

Thanks a bunch for your help!

2 Replies
Jane Booth

Worked it out... missing one vital line... duh!

var player = GetPlayer();

var email="test@myemail.com.au";
var subject="subject line"+player.GetVar("Name")
var body_start="This is the start of the body.";
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start;
win=window.open(mailto_link,'emailWin');

Anyway, hopefully this might help someone else!