Use selectedItems...

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";>
     <mx:Script>
         <![CDATA[
             private function validateData():void
             {
                 var selectedItems:Array = theList.selectedItems;
                 for(var i:int = 0 ; i < selectedItems.length ; i++)
                 {
                     trace(selectedItems[i]);
                 }
             }
         ]]>
     </mx:Script>
     <mx:List id="theList" rowCount="15" width="150"
allowMultipleSelection="true">
         <mx:dataProvider>
             <mx:ArrayCollection>
                 <mx:String>Item 1</mx:String>
                 <mx:String>Item 2</mx:String>
                 <mx:String>Item 3</mx:String>
                 <mx:String>Item 4</mx:String>
                 <mx:String>Item 5</mx:String>
                 <mx:String>Item 6</mx:String>
                 <mx:String>Item 7</mx:String>
                 <mx:String>Item 8</mx:String>
                 <mx:String>Item 9</mx:String>
                 <mx:String>Item 10</mx:String>
                 <mx:String>Item 11</mx:String>
                 <mx:String>Item 12</mx:String>
                 <mx:String>Item 13</mx:String>
                 <mx:String>Item 14</mx:String>
                 <mx:String>Item 15</mx:String>
             </mx:ArrayCollection>
         </mx:dataProvider>
     </mx:List>
     <mx:Button label="Submit" click="validateData()"/>
</mx:Application>


--- In [email protected], "brucewhealton" <[EMAIL PROTECTED]> wrote:
>
> > I'd use a list instead of a comboBox.
> >
> > Next, taking the ComboBox as an example, I could use help figuring
out
> > > how to pass the item selected by the user to the Object named obj
so
> > > that it can be passed to the php form processor.  How do I access
what
> > > the user selected?  Similarly, if I used a control that allowed
for
> > > selection of more than one item in a list, how would I access the
> > > items selected by the user?
> >
> >
> > What you want to do is create an event handler for the change event
> on the
> > list. This will fire whenever someone clicks an item in the list. In
the
> > event handler you want to look at the selected* properties
> (selectedItem,
> > selectedItems, selectedIndex, selectedIndices). These will tell you
> what the
> > user has selected in the list. At that point you can send them
> immediately
> > to your PHP script or set a local variable with their value until
> someone
> > hits a "submit" type button, or whatever happens before you send the
> values.
> >
>
> Since, this item, the list, allows for multiple items to be selected,
> you would have to wait till the submit button is clicked to gather all
> the items selected by the user, is that not correct?  But, how would
> you do that?  You can't just look at one value for the Form item when
> it is a list.  More than one item can have the "selected" property, so
> how do you find all items that have this value and return the value of
> the item selected?  And how do you access the value of the items
> selected by the user?
>
> Thanks,
> Bruce
>

Reply via email to