Pre-populate a text entry box with the contents of a variable?

Mar 14, 2022

Hey everyone. I have a project where the learner defines a term, then works through a bunch of content, then has the option to adjust his/her definition. So, I have the initial response in a variable. I would like to drag that initial definition into a new text entry field, to give the learner the option to edit it, before hitting a button to save the changes. 

I can, of course, present the old definition in a read-only text field and accept the new entry in a new text entry field. But, then, I'll need a mechanism if they don't want to change the old definition. So, I'm looking for your advice. I'm comfortable with JavaScript and willing to use it if that's a good strategy here.  

4 Replies
James Martin

I experimented more and found a solution right after I posted this!

Here's the technique: 

1. Capture your original definition into a variable (varOriginalDef) with a text entry field on a slide earlier in the project. 

2. On the slide where you want the learner to review and, possibly, edit the definition, start a trigger when the slide timeline begins, setting varRevisedDef equal to varOriginalDef

3. On the object itself (the text entry field), set a trigger that sets varRevisedDef equal to typed value when the field loses focus. 

4. Echo both variables out on a new slide to test them. 

I'll work up a demo at some point and attach it for the benefit of others.