Forum Discussion
Build Custom Search within Storyline using JavaScript
Hello, Content Creators,
In the JavaScript programming, after var key = ".....";
Yes, you should enter each of your keywords between the quotation marks. For example, if your course contained the keywords: Chicago, New York, and Los Angeles, you would enter (in any order):
var key = "Chicago New York Los Angeles";
The next action that is executed in the JavaScript code is for it to search within your keywords for whatever text the user entered in the course. Example: If the user entered Chicago, the JavaScript code searches for the character placement of the word Chicago. Then, the JavaScript code sets that value as the value of the Storyline Variable: placement.
By adding a reference (text box with %placement% text) to this Storyline variable in your course, you can easily see the value of each of your keywords that is returned once you publish the course to HTML to test it.
Example:
For the above keywords, if the user searched for Chicago, placement would be assigned a value of 0 as this keyword is found at position 0 within the text string. If the user searched for New York, placement would be assigned a value of 8. If the user searched for Los Angeles, placement would be assigned a value of 17.
You can then use this value to execute specific actions within your course. Example: Jump to slide - Chicago slide - when user clicks the search button - if placement = 0.
Hope this helps!
I figured out what I was doing wrong. For some reason, I thought that the
JavaScript was going to assign a number to slides based on their content. I
realized where I mixed things up. Thank you so much for taking the time to
respond to my question. I appreciate you.
Thanks,
Wes