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");

                          }

                          else

                          {

       

                            //  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

          Hi,

           

          Please go through following Code:

           

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

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

                                           xmlns:s="library://ns.adobe.com/flex/spark"

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

                    <fx:Declarations>

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

                    </fx:Declarations>

           

                    <fx:Script>

                              <![CDATA[

                                        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

                                        {

                                                  if(comboBox.selectedItem=="Amount"){

                                                            textBox1.editable=false;

                                                            textBox2.editable=false;

                                                  }

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

                                                            textBox1.editable=true;

                                                            textBox2.editable=true;

           

                                                  }

           

                                        }

           

                              ]]>

                    </fx:Script>

                    <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)">

                              <s:dataProvider>

                                        <s:ArrayList>

                                                  <fx:String>Amount</fx:String>

                                                  <fx:String>Percentage</fx:String>

                                  </s:ArrayList>

                              </s:dataProvider>

                    </s:ComboBox>

           

          </s:Application>

           

           

           

          Thanks and Regards,

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

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

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