Reference Tool
Jan 27, 2016
I'm trying to find an efficient way to build a reference tool to accompany some training I'm developing.
The tool should allow users to input two pieces of data, I'll call them "Code 1" and "Code 2". Then those two pieces of data need to be compared to a predefined list of possible "Code 1" and "Code 2" combination that would either allow the process to continue, stop or take an alternative route.
There are 90 different combinations between Code 1 and Code 2 that could allow or deny the process to continue.
I'm looking for ideas on how to allow users to type in "Code 1" and "Code 2" and have an yes, no or other answer returned to them after it bumps the information against the list of possible answers.
12 Replies
Hi Aaron,
The best way to accomplish this is by using Javascript but I can't really say how exactly as you aren't really clear as to what kind of data/codes your scenario entails.
Alex
Hi Aaron,
A little example is attached. Study the Javascript code in the Execute Javascript trigger. I used two arrays of sample values for Code 1 and Code 2. (I was unsure if the user's entries should be combined and compared against a single list of combined values. For now, I assumed each code will be compared against a unique list for that code.)
If a value is found in an array, Javascript will return the index (or the number of the item) where it is found. If the fifth item in the array matches the user's entry for that code, Javascript will return '4', since it begins counting from zero, not 1. If the value is not found, Javascript returns '-1'.
Hope this helps get you started! Let me know if you further guidance.
Thanks I'll take a look at this today and see what I can do with it.
I think I have the javascript in correctly but I'm receiving a Warning message that says the javascript was disabled because my browser doesn't support it. Unfortunately, my company only supports IE 9 at the moment. Would that be the problem or should I look for something else?
Sometimes Javascript will get blocked when running directly from the local drive. Publish for the web and post the files to a web server. See if that helps.
If your IT department has blocked Javascript on your computer then, no, it won't work. You'll have to resort to numerous triggers to accomplish what you want in that case.
I have the javascript set up and finally got it to run but no matter what information I input it wont' find anything in either list. I'm attaching it here. I really appreciate the help but at this point im stuck and am not sure if it's a me mistake or something else.
Here you go, Aaron.
The first line of Javascript was messed up (the actual line of code got pulled up to the end of the comment line above it) and two of your triggers needed to be tweaked (the conditions should be greater than or equal to zero, not just greater than 0; this is because index counting starts at 0, not 1).
I added a text box showing the value of the variables so you can monitor how they change. Just delete the box once everything is working to your liking.
OK Steve, I'm at my wits end. I've tried to troubleshooting the javascript but my limited knowledge is hindering me. When I run the search it's only returning a result that no code is found. Even though I am searching options that exist within each array. I went back to your original example because I thought I might have changed something incorrectly while setting up my own variables. The Code1Found and Code2Found variable never update after I click search. What am I not getting? Did your original example work accurately?
//Initiate communication between Storyline and Javascript
var player = GetPlayer ();
//Get the two values the user entered in Storyline
var Code1=player.GetVar("Code1");
var Code2=player.GetVar("Code2");
//Set up two arrays to hold all possible values of each code
var array1 = ["LPK", "CIB"];
var array2 = ["01", "10"];
//Search the respective array for the respective value the user entered
var Code1Found = array1.indexof(Code1);
var Code2Found = array2.indexof(Code2);
//If Code1Found is >-1, Code1 was found; if -1, it was not found;
//If Code2Found is >-1, Code2 was found; if -1, it was not found;
//Send the results back to Storyline
player.setvar("Code1Found", Code1Found);
player.setvar("Code2Found", Code2Found);
Hi Aaron,
Are you publishing the sample, posting the published output to a web server, and running it from the there? Javascript will often fail to function when run off a local drive.
This post was removed by the author
It could be SharePoint, or it could be the browser security settings on your computer. Try this link: http://www.gantekmultimedia.com/sl_test/array2/story.html
Enter CIC in the first box and 15 in the second box and see what happens.
I tried it in Chrome and Firefox and it works properly. If you're using another browser (say, IE), you may need to speak with an IT associate to have him/her help you adjust the security settings.
Yes I've published and moved the files to a SharePoint and then launched the story.html from there. Could SharePoint be the issue?
Ok thanks for showing me that it works. I think it may be IE. I was speaking with IT as I saw your reply. I'll see if they can help me find a solution. Thanks helping me work through it. Your help has been invaluable.
This discussion is closed. You can start a new discussion or contact Articulate Support.