Forum Discussion
Need Button To appear When Text Is Entered
You should be able to use
let inputs = document.getElementsByTagName('input');
function fnBlur(e) {
e.target.blur();
e.target.focus();
}
for (let index = 0; index < inputs.length; ++index) {
inputs[index].addEventListener("keyup",fnBlur)
}
To blur and refocus the text entry field
https://360.articulate.com/review/content/3c9f4b1e-ca64-42ec-8a89-e3979bd4dcff/review
- JennyDeller-89811 months agoCommunity Member
This is great! Thank you!
- ArmandoGarcia10 months agoCommunity Member
Is there any reason why this would not work with a SL Question block?
- aleshahonnor112 days agoCommunity Member
If you're using a Storyline Question slide (rather than a freeform slide), there's a simpler approach.
Instead of relying on the text entry variable to update (which only happens on blur), use JavaScript to detect typing in real-time and trigger button visibility through a helper variable.
JavaScript code (Execute JavaScript trigger when timeline starts):
javascript
let player = GetPlayer(); setTimeout(function() { let textareas = document.querySelectorAll('textarea'); if (textareas.length > 0) { textareas[0].addEventListener('input', function() { if (this.value.trim().length > 0) { player.SetVar("ShowSubmit", true); } else { player.SetVar("ShowSubmit", false); } }); } }, 250);
Setup:
- Create a True/False variable: ShowSubmit (default: False)
- Submit button: Initial state = Hidden
- Trigger: Change Submit to Normal when ShowSubmit = True
- Keep your Skip button always visible (or hide it when ShowSubmit = True)
Why this works: The JavaScript detects typing immediately and sets the helper variable, which triggers the button state change - no blur event needed. Users can type and click Submit in one smooth action.
Related Content
- 14 days ago