I think you don't need array notation for select.getItemAt():
 
if (select.getItemAt(i).data == optionsToSelect[i])
 
Cheers,
Philippe

________________________________

From: flexcoders@yahoogroups.com on behalf of gotjosh819i
Sent: Wed 14/12/2005 19:23
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 


        
*        Visit your group "flexcoders 
<http://groups.yahoo.com/group/flexcoders> " on the web.
          
*        To unsubscribe from this group, send an email to:
         [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> 
          
*        Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service 
<http://docs.yahoo.com/info/terms/> . 


________________________________



------------------------------------------------------------------
**STATEMENT OF CONFIDENTIALITY** 

This e-mail and any attached files are confidential and intended solely for the 
use of the individual to whom it is addressed. If you have received this email 
in error please send it back to the person that sent it to you. Any views or 
opinions presented are solely those of author and do not necessarily represent 
those the Emakina Company. Unauthorized publication, use, dissemination, 
forwarding, printing or copying of this email and its associated attachments is 
strictly prohibited.

We also inform you that we have checked that this message does not contain any 
virus but we decline any responsability in case of any damage caused by an a 
non detected virus.
------------------------------------------------------------------



------------------------ 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/
 

<<winmail.dat>>

Reply via email to