PDA

View Full Version : return multiple values from a list box


ljonny18
11-22-2006, 01:22 PM
hi I have a listBox (<mx:List>) that is populated by a webService acting as its dataProvider ("myDataProvider")......

within the listBox the value shown from the dataProvider is the "customerName", there is also a customerID values within the dataProvider.

I have set the "allowMultipleSelection" equal to true so that more than one row / value can be selected.

I want to retrieve all of the ID (customerID) valause from all of the selected rows within the listBox.

if I use the following:
var myObj:Object = new Object;
myObj.id = myListt.selectedItem.CUSTOMERID;

it works - but only returns 1 single ID value (the first selected etc) when I change "selectedItem" to "selectedItems" it does not return anything:

var myObj:Object = new Object;
myObj.id = myListt.selectedItems.CUSTOMERID;

can anyone help me out here.... ?

thanks,
Jon.

Tink
11-22-2006, 01:59 PM
if you looked at the docs you would see that selectedItems returns an Array.var numItems:int = myList.selectedItems.length;
for( var i:int = 0; i < numItems; i++ )
{
trace( myList.selectedItems[ i ].CUSTOMERID );
}

Anil_kumar
01-09-2009, 04:44 AM
Great :)

if you looked at the docs you would see that selectedItems returns an Array.var numItems:int = myList.selectedItems.length;
for( var i:int = 0; i < numItems; i++ )
{
trace( myList.selectedItems[ i ].CUSTOMERID );
}