JavaScript for Multiple Fields: Numeric and Data Entries

Hello! I'm trying to execute Java script for two variables on a slide: data entry and numeric entry fields. I would like the user to enter Yes or No in the data field and then a ticket number in the numeric field and when they click the Submit button, it will generate an email with their answers populated in the email body. See attached picture. Here is my JavaScript:

var email='email@hotmail.com';
var player = GetPlayer();
var subject="Email Subject Line";
var body_start=player.GetVar();
var body_start=player.("NumericEntry1");
var body_start=player.("TextEntry");
body_text = body_start;
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_text;
win=window.open(mailto_link,"emailWin");

I have used a version of this java script to successfully generate an email for one variable in the past but I'm trying to add multiple variables and it's not working. Any suggested edits for the script would be much appreciated!

Thanks in advance!

3 Replies
Matthew Bibby

There are a number of issues with your code.

Try this instead:

var player = GetPlayer();
var email='email@hotmail.com';
var subject = "Email Subject Line";
var numEntry = player.GetVar("NumericEntry1");
var texEntry = player.GetVar("TextEntry");
var body_text = "This is the text that will be in the email. Here is the number: " + numEntry + " and here is the text: " +texEntry;
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_text;
win=window.open(mailto_link,"emailWin");

This assumes that you have the variables NumericEntry1 and TextEntry in your project.

Demo here.

To learn more about how this works, see here