Forum Discussion
go to new layer when text has been entered in text box
Hi. I have a text box where the user is supposed to enter the number 68, and then I want that specific number to trigger the opening of a new layer without having to enter any other key such as ENTER. The number itself should trigger the layer. Is this possible? I'm assuming I would need some JavaScript maybe? Thank you.
- NedimCommunity Member
I think you could use a bit help of Javascript. Something like this:
const textFields = document.querySelectorAll('.acc-textinput');
textFields.forEach((textField) => {
textField.addEventListener('keyup', () => {
textField.blur();
});
});
Put this code in 'Execute Javascript when the timeline starts on this slide' trigger.
The blur() method will remove keyboard focus from the current element. Create a trigger in SL to say: Show layer 'correct' when 'NumericEntry' changes if 'NumericEntry' = value 68. As soon as you type 68 into the input field another layer will show up.- AprilDrennan-f8Community Member
I'll give it a try. Thank you!
- PhilMayorSuper Hero
- AprilDrennan-f8Community Member
I'm having trouble opening this file for some reason. It could be something on my end I suppose. I will keep trying. Thanks for responding!
- AprilDrennan-f8Community Member
I got it to work. It's perfect. Thank you!
- PhilMayorSuper Hero
It uses the similar code that Nedim posted, I just had this lying around from something else.
Sent from my iPhone
- PhilMayorSuper Hero
You may need to update to the latest version