4 Replies Latest reply on Apr 5, 2010 7:33 AM by David_F57

    RadioButton Question

    choisington Level 1

      Why does this not work?

       

      public function getCategoryRadioButton(categoryNo:int):void
          {
              if (categoryNo == 2)
              {
                  governmentRadioButton.selected = true;
              }
              else if (categoryNo == 3)
              {
                  academicRadioButton.selected = true;
              }

         }

       

      OR THIS???

       

      public function emailBooleanSet(doNotEmail:String):void
          {
              if (doNotEmail == 'n')
              {
                  emailCheckBox.selected=true;
              }
              else if (doNotEmail == 'y')
              {
                  emailCheckBox.selected=false;
              }
          }

       

      ???????????

        • 1. Re: RadioButton Question
          choisington Level 1

          Ok well I figured out that you can reference the label of the radiobutton from the group name.

           

          Survey1.selectedValue = 'While browsing the website';

           

          But how is it done for a checkbox. This seems like an easy question, but I just can't figure it out.

          • 2. Re: RadioButton Question
            David_F57 Level 5

            Hi,

             

            http://gumbo.flashhub.net/radiocheck/ source enabled

             

            This may give you what you need - The logic assumes you are treating the checkbox like a radiobutton, you could always reskin a radiobutton if you wanted it to look like a checkbox.

             

            David

            1 person found this helpful
            • 3. Re: RadioButton Question
              choisington Level 1

              That does help, but I am still curious why it is saying "can not access propert of null object" My input that I pass in is not null, I checked by displaying it in an alert.

               

              This really is a mystery to me.

              • 4. Re: RadioButton Question
                David_F57 Level 5

                Hi,

                 

                Maybe its the way the 'if' is done, possibly the better way would be to use a switch statement so that if there is a problem with the passed parameter it wouldn't break the code.

                 

                 

                switch(category)

                {

                case 0: rb1.selected = true;

                case 1: rb2.selected = true;

                case 2: rb3.selected = true;

                case 3: rb4.selected = true;

                }

                 

                just a thought

                 

                 

                David.

                 

                [edit] also for the other if statement i would do it this way

                 

                if (noemail=='n')  checkbox=true else checkbox=false;