1 Reply Latest reply on Sep 20, 2011 11:06 PM by Vibhuti Gosavi(InfoCepts)

    how to write save function based on combo box selection datas in flex4 mxml app with as3

    Venkatesan Balasubramanian Level 1

      hi all,



        i am working on flex4 web application with as3.


      i have one doubt, i created a mxml it have two text boxes,one save button and one combo box .its has two option like Percentage and amount.


      my needs are i given here,




            need 1:   when i select amount option that two text boxes should be not editable.when i select percentage option tat two text box will be editable.

            need 2:   when i select percentage option in combox and that two text boxes are empty then click save button --->i want to display warning msg

            need 3:   when i select amount option in combox and that two boxes are emptu click save button--->i dont want any warning message.


      how i validate this and how i write save function for this.


      this is my sample code:



      combo box id=baseAmtPer

      textbox1 id= maxCommAmt.text

      text box id=baseAmtPer.text


      if(((baseAmtPer.editable!=true)&&(maxCommAmt.editable!=true))&&((baseAmtPer.text=="")&&(ma xCommAmt.text==""))||(baseAmtPer.text=="")||(maxCommAmt.text==""))-->this condition not allowing while i am selecing Amount in combo box BOTH TEXT BOX WILL BE EMPTY .how to solve this issue


                              Alert.show("Enter All fields", "Information");





                            //  some codings


        • 1. Re: how to write save function based on combo box selection datas in flex4 mxml app with as3
          Vibhuti Gosavi(InfoCepts) Level 3



          Please go through following Code:


          <?xml version="1.0" encoding="utf-8"?>

          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"


                                           xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">


                              <!-- Place non-visual elements (e.g., services, value objects) here -->





                                        import mx.collections.ArrayCollection;

                                        import mx.controls.Alert;

                                        import spark.events.IndexChangeEvent;



                                        protected function button1_clickHandler(event:MouseEvent):void


                                                   if(comboBox.selectedItem=="Percentage" && textBox1.text=="" && textBox2.text==""){


                                                             Alert.show("Enter values");




                                        protected function comboBox_changeHandler(event:IndexChangeEvent):void






                                                  else if(comboBox.selectedItem=="Percentage"){










                    <s:Button x="99" y="227" label="Save" click="button1_clickHandler(event)"/>

                    <s:TextInput x="99" y="104" id="textBox1"/>

                    <s:TextInput x="329" y="104" id="textBox2"/>

                    <s:ComboBox x="346" y="225" id="comboBox" change="comboBox_changeHandler(event)">













          Thanks and Regards,

          ------------------------------------------------------------------------------------------ --

          Vibhuti Gosavi | vgosavi@infocepts.com | www.infocepts.com

          ------------------------------------------------------------------------------------------ --