You're assigning the index to the selectedIndices variable, you need to modify the array.
var toSelect:Array = []; for (...) if (...) toSelect.push(i); select.selectedIndices = toSelect; HTH, Matt -----Original Message----- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of gotjosh819i Sent: Wednesday, December 14, 2005 10:23 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] selecting items in a listbox based on a query result I am having some issues selecting the items in a listbox based on a selection return result from a GRID. I basically run a function pageListChanged() when someone selects an item in a grid. That functions gets some data from a Coldfusion CFC and returns the result. I then want to select items in a listbox based on that result so the user can make changes if they want to. heres how I am trying to select the items in the listbox, but its not selecting it. (note i hard coded in the results so u can see what I am returning from my CFC) sooo what am i doing wrong here? Listbox code: <!--- helper function to select items in a list ---> public function selectList(select: mx.controls.List, optionsToSelect:Array):Void{ //go through every record to find the right one for (var i:Number = 0; i < select.length; i++) { if (select.getItemAt([i]).data == optionsToSelect[i]){ select.selectedIndices = i; break; } } } Heres the code calling the function above and passing data: var Roles:Array = Array(4000, 4001, 4002); <!--- Listbox --note using helper function from below to select right options---> _root.selectList(_root.edit_Roles, Roles); ***********************THIS CODE WORKS FINE BELOW******************* Code I used for combobox (works great) function: <!--- helper function to select items in a dropdown - --> public function selectOption(select: mx.controls.ComboBox, optionToSelect:String):Void{ //go through every record to find the right one for (var i:Number = 0; i < select.length; i++) { if (select.getItemAt([i]).data == optionToSelect){ select.selectedIndex = i; break; } } } calling function code: var subjectID:Number = 7000; <!--- ComboBox -- note using helper function from below to select right options---> _root.selectOption(_root.edit_navSubject, subjectID); ******************************************************************** -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links ------------------------ Yahoo! Groups Sponsor --------------------~--> Most low income homes are not online. Make a difference this holiday season! http://us.click.yahoo.com/5UeCyC/BWHMAA/TtwFAA/nhFolB/TM --------------------------------------------------------------------~-> -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/