Copy link to clipboard
Copied
Hi everyone,
I've read a bit about listboxes online, but I still cannot find out, how to load an array into a listbox widget (I chose the one from learner interactions in Captivate 10). The listbox states a variable that I named listbox_own, but it only saves the choice of the user in this variable. However, I want to load the content from a variable. Is that possible?
I've tried as onload event on the slide the following, but it doesn't work
var myArray = [ "cat", "dog", "snake"];
window.cpAPIInterface.setVariableValue( "listbox_own", myArray);
Best regards
Max
Copy link to clipboard
Copied
Indeed, that variables is only used to store the result of the choice by the learner. It cannot be used to populate the items in the listbox.
What do you want to do with the listbox? Maybe you misunderstand its purpose.
Copy link to clipboard
Copied
I want to add all the items from an array, and load the content for the array from an external file. Is there any other way to do this?
Thanks for your quick reply!
Copy link to clipboard
Copied
You will need to look for another solution, create your own list with each item being an inserted user variable. Then it is possible to use the interface to populate those variables. You cannot just use a complete array to fill something, you'll need to write a function that puts each of the elements of the array in a different variable.
You didn't answer my question: what do you want to do with that listbox in Captivate? It is meant as an alternative for the radio buttons widget, where the learner will chose an item and based on that item another action will occur.
Copy link to clipboard
Copied
Thank you for your answer.
"what do you want to do with that listbox in Captivate? It is meant as an alternative for the radio buttons widget, where the learner will chose an item and based on that item another action will occur."
I want users to choose items, however I want to load the content dynamically from a file and populate the listbox with it, so that I can change the content of the listbox without further changes in captivate by just changing the file.
Copy link to clipboard
Copied
I don't know about a way to populate those items, the source code of that widget is not available.