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
player.SetVar("fn",firstname);
I'd appreciate any assistance with this problem. Simple I'm sure for a JavaScript person. Thanks....
Paul
6 Replies
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: http://dev.keypointlearn.com/xcl73_SL2/JSTEB/V1/story.html
Michael,
I believe you've got something here. I'll try it and let you know. Thanks
very much for your help!
Paul
For additional information on properly testing your published content, please review this article.
Michael,
Yes Sir! That worked. Thank you so much for your help!
Paul
Ashley,
Obviously, you read my mind because that was my next question - how to
publish to another place like Google Drive? I just tried the advise given
in the article you provided and it worked like a charm.
Thanks for your help!!!
Paul
Thanks for the update Paul and glad everything worked for you!
This discussion is closed. You can start a new discussion or contact Articulate Support.