2 Replies Latest reply on Jun 23, 2010 5:03 AM by xpsdeset

    list get value

    xpsdeset

      I am new to flex.

       

      I have id as value for a item in the list and room_name as the label.

      Due to the automatic binding it does show the label.

      But i want to get the value of the selected item.

       

      I mean below is html of what I want to do

      <select name="list" onchange="alert(this.value)">
      <option value="cdcol" >cdcol (1)</option>
      <option value="chatbox" >chatbox (9)</option>
      </select>
      
      

       

      This is my flex code

      <s:List x="13" y="18" width="118" height="400" id="list"  labelField="room_name"   change="list_changeHandler(event)">
                <s:AsyncListView list="{getAllroomsResult.lastResult}"/>
           </s:List>
      
      
        • 1. Re: list get value
          BhaskerChari Level 4

          Hi xpsdeset,

           

          You can make use of the selectedItem property of the list..

           

          var selItem:Object = list.selectedItem;

          and you can access/get the selected item label as selItem.selectedLabel

           

           

          If this post answers your question or helps, please kindly mark it as such.


          Thanks,

          Bhasker Chari

          • 2. Re: list get value
            xpsdeset Level 1

            thanks a lot i modifyed you code and it worked ausome.

             

            protected function list_changeHandler(event:IndexChangeEvent):void
            
                        {                debug.text=list.selectedItem.id;
            
                            getAllUsersResult.token = usersService.getSetRoom(list.selectedItem.id);
            
                        }
            

             

            thanks a lot Bhasker Chari.