Javascript variables in Storyline


I'm having trouble referencing variables on frames that occur after they are declared. For example, on the first frame of a course, on the last line successfully opens the window with passURL as the URL.

//Ask the LMS object to get the name
var rawName = lmsAPI.GetStudentName();
var rawID = lmsAPI.GetStudentID();
var Office = 0;
var Field = 0;
var Drive = 0;
var passURL = ""+rawID+"&office="+Office+"&field="+Field+"&drive="+Drive;;

However, the following code on the next slide breaks JavaScript entirely so that no JS in the course works at all:;

If I replace the passURL with a regular URL on the second frame, the window opens and everything works."");

What am I doing wrong? How can I successfully reference passURL (and all the variables in encompasses) from any frame in the course? Does it need a GetVar? (That doesn't seem to fix the problem, but maybe I'm doing it wrong.)


Thank you!

3 Replies
Karessa Torgerson

This works!

//Ask for the Articulate player

var player1 = GetPlayer();

var urlID = player1.GetVar("rawID");
var urlOffice = player1.GetVar("Office");
var urlField = player1.GetVar("Field");
var urlDrive = player1.GetVar("Drive");

var passURL = ""+urlID+"&office="+urlOffice+"&field="+urlField+"&drive="+urlDrive;;