JavaScript to Capture Full Name and then split into First and Last Names

Jan 26, 2015

I'm trying to capture a full name in a Text Entry box in Storyline, split it up into its first and last name parts and then use each part as necessary.  For Example, I'd like to be able to refer to the user by first name in order to say "Good Work Frank".

Here is my Javascript: (I'm just starting off with JavaScript)

var player=GetPlayer();

//Assign variable to full name typed in box in Storyline

var fullname=player.GetVar("Fullname");

//Split full name into two parts with a space as the seperator
var name=fullname.split(" ");

//Assign variables to each part that I split the full name into
var firstname=name[0];
var lastname=name[1];

//Set fn variable in Storline (represents first name) to value of firstname

I'd appreciate any assistance with this problem.  Simple I'm sure for a JavaScript person.  Thanks....



6 Replies
Michael Hinze

There doesn't seem to be anything wrong wit your script. I guess you published and tested locally (on your harddrive). In that case, the script is blocked by your browser's security setting. Upload to some server and test again. I uploaded it to my server and, unless I'm missing something, it works for me. See here:

This discussion is closed. You can start a new discussion or contact Articulate Support.