Forum Discussion
Setting Data Entry Object Focus & Auto-Advance to Next Slide When Correct Value is Entered
- 7 months ago
See the attached .story file. Let me know if it worked for you.
Thanks, Nedim,
Your JavaScript worked!!! I truly appreciate your JS knowledge. Your code makes sense. Once I publish the course to Review 360, I will need to make sure the slide still functions as intended.
I did see the Event Listener command on https://www.w3schools.com/ but still trying to understand the JS statements and syntax. I will definitely pursue the tutorials at https://www.w3schools.com/ much further.
For the benefit of others in this great community, here is the coding Nedim provided (I added some comments - Nedim, are my comments a correct description of the coding?):
-----------------------------------
// Setting JS variable:
var input = document.querySelector('.acc-textinput');
// Setting focus on the data entry field:
setTimeout(() => {
input.focus();
}, 100);
/*
Use value of JS variable and assign directly to the Storyline
project variable instead of manually setting an object trigger to set
the variable to the typed value that requires an event on the object
such as loses focus.
*/
input.addEventListener('input', function() {
var inputValue = input.value;
setVar('WordProfile_SC', inputValue);
});
--------------------------
Then, the separate trigger with conditions for jumping to the next slide will process.
If I have further questions, I will add to this post. The Storyline community is the best!