Forum Discussion
Text entry boxes - update value without losing focus
- 4 days ago
There are several solutions in the community for this. Instead of forcing the focus to move, we can tell the browser to 'listen' for any input activity within the text box and manually push that value into your Storyline variable in real-time. By using an EventListener, we update the text entry variable directly without the input field ever losing focus. Check the example below:
const inputField = document.querySelector('.acc-textinput'); inputField.addEventListener('input', function() { let currentVal = inputField.value; setVar("userEntry", currentVal); }); // optional input round border inputField.style.cssText += "border-radius:50px !important; border:1px solid #fff !important;";
There are several solutions in the community for this. Instead of forcing the focus to move, we can tell the browser to 'listen' for any input activity within the text box and manually push that value into your Storyline variable in real-time. By using an EventListener, we update the text entry variable directly without the input field ever losing focus. Check the example below:
const inputField = document.querySelector('.acc-textinput');
inputField.addEventListener('input', function() {
let currentVal = inputField.value;
setVar("userEntry", currentVal);
});
// optional input round border
inputField.style.cssText += "border-radius:50px !important; border:1px solid #fff !important;";
- JudyNollet3 days agoSuper Hero
I've repeatedly suggested to folks at Articulate that Nedim deserves SUPER HERO status. He's earned the cape!
- PhilMayor3 days agoSuper Hero
+1 from me
- Nedim2 days agoCommunity Member
JudyNollet PhilMayor Thank you both! My two favorite heroes. Judy, this cape is incredible, you even guessed my size right!
- WebsterR1012 days agoCommunity Member
Thank you. This did the trick! :)
- Nedim2 days agoCommunity Member
Great!
Related Content
- 5 months ago