Get an array from a listbox
Hi!
I'm new in javascript and I'm having a trouble I can't fix. ![]()
I've wrote a script for Indesign and I want obtain and array from a multiselect listbox.

The way I wrote I think I've two problems right now:
- The variable isn't working outside the function (for example, if I put an alert for "listOne" inside the function it prints the names I had selected. But, when I do the same outside the function it tells me "Object Invalid". It also alerts that "[Object ListItem]".
- I think the list is creating an object and, in order to work for me I need an array. Is there any way to convert the object into an array? I've tried a few things like keys and similar, but don't really know how to work with it.
Thanks anyway! rs
var listOne;
listParticipants();
function listParticipants(){
//window preferences
var myWindow = new Window ("dialog", "Definição dos Participantes");
var groups = myWindow.add("group");
groups.orientation = "row";
var group1 = groups.add("panel");
group1.orientation = "column";
var list1 = group1.add ("listbox", undefined, ["cat", "dog", "horse", "mouse"], {multiselect: true});
var group2 = groups.add("panel");
group2.orientation = "column";
var list2 = group2.add ('listbox', undefined, ['one', 'two', 'three'], {multiselect: true});
var group3 = groups.add("panel");
group3.orientation = "column";
var list3 = group3.add ('listbox', undefined, ['one', 'two', 'three'], {multiselect: true});
var button = myWindow.add("button", undefined, "OK", {name:"ok"});
button.alignment = "right";
myWindow.show ();
//defining the list
listOne = list1.selection;
alert (listOne)
}
alert (listOne)
