Use JavaScript to Slice() First Name from Text Entry Variable Jun 10, 2020 By Cody Salinas I am a JS noob and looking for some help when storing a new variable. Please excuse my noobness in advance. I want to take a text entry (userName) and display only the first word typed. I've highlighted my name as the text entry variable (userName). I want to only display the first name on this screen. Here's the execute JavaScript code I've placed in Storyline. I want to turn userName into firstName and display %firstName% on a slide. Thanks in advance! Any expert guidance will help me a ton.
Walt Hamilton Hero almost 4 years ago06/10/20 at 5:42 pm (UTC) You need to get the variable from SL first, so js has something to work on. var player = GetPlayer(); var name = player.GetVar("NameOfUserNameInSL"); Then you can manipulate name and return the part you want, using the player.SetVar statement.
2 Replies
You need to get the variable from SL first, so js has something to work on.
var player = GetPlayer();
var name = player.GetVar("NameOfUserNameInSL");
Then you can manipulate name and return the part you want, using the player.SetVar statement.
Thank you!
This discussion is closed. You can start a new discussion or contact Articulate Support.