Generate textbox in a loop or from javascript

May 10, 2016

I'm working with a colleague to integrate a number of small storyline applications into a larger mixed media application we are developing. We want a list of "messages" received elsewhere in the application to display within a storyline page but we have run into a wall. To ensure it will not need to heavily modified in the future we would like it to work with any number of messages but we're having some trouble getting storyline to display them.

I have exposed a JSON endpoint and written a basic XHR request we can place in storyline to fetch the data and assign it to variables. Despite storyline variables not permitting arrays we have currently worked around it by creating variables in a loop.

player.SetVal('messageCount', messages.length);

for(var i = 0; i < messages.length; i++) {

  player.SetVar('message' + i, messages.subject);

}

As far as I can tell that seems to work except that we can't create the textboxes to show this data in a loop. So I wonder, is there any way we can generate new textboxes either within storyline or a javascript function for each message variable?

 

Thank you

4 Replies
Matt Elvey

Thanks Manjunath and Christie. I actually need to use these textboxes as buttons so parsing the text and placing it in a single long textbox won't work unless I can map the click action to the particular text line.

Christine, the problem isn't with javascript itself beyond asking if you provide an API to create storyline objects. As my code snippet indicates I can push data into storyline variables but have no way to loop through them from within storyline. I was rather hoping that storyline might provide some sort of loop operation or a javascript API that I can use to access this functionality.

Christie Pollick

Hi, Matt -- Thanks for your reply and for the additional details. Unfortunately, Storyline does not offer an API or loop functionality, but if you'd like to share your thought with our Product team, here is the form you would need to do so. Otherwise, perhaps your fellow community members can share additional ideas to assist! :)

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