0

Hello everyone I am new to flex so please excuse if it is noob question.
I have 2 comboboxes which are dependent (country and state) and one submit button.
Now what i want is after user submits the form it should display one alert box which should be like

selected country is "selected item"
selected state is"selected item"

Thanks

Hertzel Guinness
  • 5,912
  • 3
  • 38
  • 43
vardit
  • 29
  • 6

3 Answers3

3

Here is a sample in its simple form

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" minWidth="955" minHeight="600">

    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;
            protected function button1_clickHandler(event:MouseEvent):void
            {
                Alert.show("Selected country is "+'"'+cm1.selectedItem+'"\n'+"Selected state is "+'"'+cm2.selectedItem+'"');
            }
        ]]>
    </mx:Script>

    <mx:ComboBox id="cm1" width="150" dataProvider="['a1','b1','c1']"/>
    <mx:ComboBox id="cm2" width="150" dataProvider="['a1a','b1b','c1c']"/>
    <mx:Button label="Submit" click="button1_clickHandler(event)"/>
</mx:Application>
user700284
  • 13,540
  • 8
  • 40
  • 74
0
  • For getting each combobox selected item as text use selectedItem.label. see here.
  • For popping alerts use Alert.show. see here.
  • For string building use + operator.

Good luck.

Hertzel Guinness
  • 5,912
  • 3
  • 38
  • 43
0
    <?xml version="1.0"?>
<!-- dpcontrols/ComboBoxEvent.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >
   <mx:Script>
      <![CDATA[
         import mx.controls.Alert;
      ]]>
   </mx:Script>

   <mx:ComboBox id="mycb"> 
      <mx:ArrayCollection>
         <mx:Object label="AL" data="Montgomery"/>
         <mx:Object label="AK" data="Juneau"/>
         <mx:Object label="AR" data="Little Rock"/>
      </mx:ArrayCollection>
   </mx:ComboBox>
     <mx:ComboBox id="mycb2"> 
      <mx:ArrayCollection>
         <mx:Object label="US" data="United States"/>
         <mx:Object label="MX" data="Mexico"/>
         <mx:Object label="IR" data="Ireland"/>
      </mx:ArrayCollection>
   </mx:ComboBox>
   <mx:Button id="button1" label="Submit" click="Alert.show('Submit Successful!  State: '+{mycb.selectedItem}+' Country:'+{mycb2.selectedItem}, 'Alert Box', mx.controls.Alert.OK);"/>
" width="100"/>
</mx:Application>
garnertb
  • 9,454
  • 36
  • 38