3 Replies Latest reply on Nov 11, 2009 12:39 PM by salem_b_a

    Combobox Question

    RosieGp Level 1

      I have a combobox giving 3 different options to user.

      Make a selection:

      Book

      Table

      Chair

       

      If they select Book I was the name of the Book to appear only, if table only the table name, if chair only the chair name.

      So if Book is selected how to only dispaly name of the book.. at the same area

       

      For example:

      Flex 3 In Action is replaced by table name OAKWOOD Table etc...

      so it appears at the same at the same spot...

       

       

       

       

       

       

      <mx:ComboBox

       

      id="object" x="10" y="494" prompt="Select Object">

       

       

         <mx:ArrayCollection>

                <mx:String>Book </mx:String>

       

       

       

       

                <mx:String>Table </mx:String>

                <mx:String>Chair </mx:String>

       

       

       

       

         </mx:ArrayCollection>

       

       

      </mx:ComboBox>

      <mx:Label text="Flex 3 in Action">

      <mx:Label text="Oak Wood Table">

      <mx:Label text="Red Oak Chair">

       

      Any help is appreciated........

        • 1. Re: Combobox Question
          salem_b_a

          hi,

          there are too many ways to do that, i will suggest the simplest (in my opinion )

          <mx:ComboBox id="object" x="10" y="494" prompt="Select Object"  click="displaySelected()">

             <mx:ArrayCollection>

                        <mx:Object label="Book" data="bookName"/>

           

                         <mx:Object label="Table" data="tableName"/>

           

                         <mx:Object label="Chair" data="chairName"/>

             </mx:ArrayCollection>

          </mx:ComboBox>

          <mx:Label id='name'/>

          <mx:Script>

                    <![CDATA[

           

                         //you may need some import here

           

                         public function displaySelected(){

                                   name.text = selectedItem.data;

                         }

                    ]]>

           

          </mx:Script>             

           

          Application, i want you to try with event.currentTarget for the purpose

           

          Hope this helps,

          Salem

          1 person found this helpful
          • 2. Re: Combobox Question
            RosieGp Level 1

            what if I have to provide a text box so that they can enter the name for example:

             

             

               <mx:ArrayCollection>

                          <mx:Object label="Book" data="bookName"/>

            //suppose here i want the user to enter the name of the book so TEXT BOX and i want to enter Name at the end

            //so something like data="[TextBox]Action"/>

             

                           <mx:Object label="Table" data="tableName"/>

             

                           <mx:Object label="Chair" data="chairName"/>

               </mx:ArrayCollection>

            </mx:ComboBox>

            <mx:Label id='name'/>

            <mx:Script>

                      <![CDATA[

             

                           //you may need some import here

             

                           public function displaySelected(){

                                     name.text = selectedItem.data;

                           }

                      ]]>

             

            </mx:Script>            

             

            <mx:ComboBox id="object" x="10" y="494" prompt="Select Object"  click="displaySelected()">

            • 3. Re: Combobox Question
              salem_b_a Level 2

              try this

               

               

              public function addComboItem():void{

              var obj:Object = new Object();

              obj.label =yourEntry.text;

              obj.data = yourEntryValue;

              yourCombo.addItem(obj);

              }

               

               

              if any answer helped, please mark so

              Salem