3 Replies Latest reply on Sep 21, 2011 12:09 AM by pramod.rao

    how to validate and saving the values of one combo box and two text boxes in flex4 mxml app with as3

    Venkatesan Balasubramanian Level 1

      helllo 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.

       

       

      any suggession or snippet codes are welcome.

       

      Thanks in advance,

       

      B.venkatesan

        • 1. Re: how to validate and saving the values of one combo box and two text boxes in flex4 mxml app with as3
          pramod.rao Level 1

          This is simply putting your logic into code. Why do you need code snippets for this?

          • 2. Re: how to validate and saving the values of one combo box and two text boxes in flex4 mxml app with as3
            Venkatesan Balasubramanian Level 1

            hi pramod,

             

            i already tried this but ,in that one condition is working bt another one not working i am giving my code here,

             

            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))&&((baseA  mtPer.text=="")&&(maxCommAmt.text==""))||(baseAmtPer.text=="")||(maxCo mmAmt.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

            }

             

             

            send ur useful suggession

             

             

            Thanks ,

             

            B.venkatesan.

            • 3. Re: how to validate and saving the values of one combo box and two text boxes in flex4 mxml app with as3
              pramod.rao Level 1

              Looks like you are trying to do too much at one time. Try hooking the events properly

              The comboBox close event can do something like this

               

              protected function toggleTextEditing(event:DropDownEvent):void

              {

                             if(this.optionCmb.selectedItem.label == "Percentage")

                             {

                                       this.text1.editable = true;

                                       this.text2.editable = true;

                             }

                             else if(this.optionCmb.selectedItem.label == "Amount")

                             {

                                       this.text1.editable = false;

                                       this.text2.editable = false;

                             }

              }

               

              The button click event can do something like

               

              protected function save(event:MouseEvent):void

              {

                       if(this.optionCmb.selectedItem.label == "Percentage")

                             {

                                            if(this.text1.text == "" && this.text2.text == "")

                                            {

                                                           Alert.show("Text is empty");

                                                           return;

                                   }

                                   else

                                   {

                                   }

                             }

                             else if(this.optionCmb.selectedItem.label == "Amount")

                             {

                             }

              }

               

               

              If you can put in your entire code, may be I can have a look at it to see if I can find anything wrong there.

               

              -Pramod

              http://www.flexmycode.com