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!
Thank you for the reply. I'm still missing something.
How does the code know which keyword is tied to each slide? Do I type the
keywords onto the slides? I'm not sure how the JavaScript knows that a
specific slide is tied to a specific term, that is the part I don't
understand.
Let's say for example, I'm going to use the following keywords for Slide
2.1 (Scene 2, Slide 1):
- Keyword 1 - Conflict Resolution
- Keyword 2 - Resolving Conflict
- Keyword 3- Difficult Customers
What do I actually place on the slide so that the JavaScript knows that
those keywords are meant for that specific slide location?
Thanks,
CC