1 Reply Latest reply on Sep 30, 2012 5:58 AM by BrianJ011980

    Select Item in combobox/dropdown, fields get updated

    BrianJ011980

      Hello,

       

      I have a dropdown. When a user makes a selection, I would like to query a database and then return the results to be dispayed in a form. Note, I don't want users to have to press a button, it should happen when an item is pressed. It sounds fairly simple but, because i'm new, i'm struggling.

       

      I understand I need to create a 'change' handler, and then within this handler, I need to execute my service t get the data, but then when I try to access this data, nothing happens. Do I have to Bind something to the combobox? below is my code.

       

      <s:ComboBox id="lcidComboBox" change="lcidComboBox_changeHandler(event)" labelField="name" selectedItem="{bills.locn}">

      <s:AsyncListView list="{getLocationsResult.lastResult}"/>

      </s:ComboBox>

       

      protected function lcidComboBox_changeHandler(event:IndexChangeEvent):void

      {

        getLocationsResult.token = locationService.getLocations();

        trace(locations.snam); <---this is not returning anything!! 

      }

       

      Cheers,

      Brian

        • 1. Re: Select Item in combobox/dropdown, fields get updated
          BrianJ011980 Level 1

          OK, figured it out. I needed to include a Binding tag then in my call responder, the object is able to be called and I can acces its properties.

           

          <fx:Binding source="lcidComboBox.selectedItem as Locations" destination="locations"/>

           

          protected function lcidComboBox_changeHandler(event:IndexChangeEvent):void

          {

          getLocationsResult.token = locationService.getLocations();

          snamTextInput.text = locations.snam;

          cuidTextInput.text = locations.cuid;

          }