Forum Discussion
Need Button To appear When Text Is Entered
Is there any reason why this would not work with a SL Question block?
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
- 10 days ago