Displaying a variable in an input box?

May 03, 2018

Say I have a text variable named 'greeting' with a default value of 'hi'. 

textbox with %greeting% displays 'hi'

input box with %greeting% displays %greeting%

Can I not do this?

4 Replies
Andrew Hanley

Doubtful Ryan as they use two different methods to render the text.

If I was trying to solve that problem I would use Javascript running on the input field, or perhaps simpler (depending on what you want to achieve) is to put a text field behind the input field and have the variable display there.

As soon as a user clicks on the input field to type, you can hide the variable text.

Kind of like one of those web forms that says "Enter name" in light grey which magically disppears when you start typing.

Not sure if any of that helps! :)

Ryan Thomson

Yay! Got it sorted with some Javascript. For anyone wanting to load a Storyline variable in to an input text field, here's my code:

First I execute this on timeline start where userMadeList is my original list I want to access and listUpdate is the new text entry for learners to update their list.

var player = GetPlayer();
var userMadeList = player.GetVar("userMadeList");
player.SetVar("listUpdate", userMadeList);

Then I execute this Javascript when the listUpdate text fields updates:

var player = GetPlayer();
var listUpdate = player.GetVar("listUpdate");

player.SetVar("userMadeList", listUpdate);

 

This discussion is closed. You can start a new discussion or contact Articulate Support.