2 Replies Latest reply on Aug 11, 2008 3:05 PM by alice_data

    Setting Radio Button Selected

      This should be simple, but I cannot successfully set one of the radio buttons as selected based on the radio button group selectedValue attribute. I select an item in a data grid that populates the userVO. This is working for sure because all my other form fields get populated as expected based on binding to the userVO. If the userVO.CompanyType is equal to the radioButton value or id, I would expect that particular radio button to become selected.

      Sample Code:

      <mx:RadioButtonGroup id="CompanyType" selectedValue="{userVO.CompanyType}" />

      <mx:RadioButton label="Retailer" groupName="CompanyType" value="Retailer" />

      <mx:RadioButton label="Maintenance" groupName="CompanyType" value="Maintenance" />

      I thnk I have coded this per the documentation, but I cannot find a working example anywhere of how to set a radio button to selected. Any comments or thoughts are appreciated.
        • 1. Setting Radio Button Selected
          dimival Level 1
          Use the selectedValue property of the RadioButtonGroup:

          RadioButtonGroup selectedValue = valueOfRadioButton
          RadioButton value= valueOfRadioButton

          when you set the selectedValue property on the RadioButtonGroup it will select the matching RadioButton.

          I tried to paste the full code of the example but the forum is messing it up, just like your post. Hope this helps you out
          • 2. Re: Setting Radio Button Selected

            As I am trying to go through instructions on how to post the data values in the radio buttons, or combo boxes into databases, I noticed this post. The typical example I have is here in the following:

            <mx:RadioButtonGroup id="gender"/>
            <mx:FormItem label="Sex" y="90" width="217" direction="horizontal">
            <mx:RadioButton groupName="gender" value="F" label="Female" width="85" />
            <mx:RadioButton groupName="gender" value="M" label="Male" width="50"/>

            This is how I am trying to post it to the online database:

            I checked the result in the database, and there is a new entry inserted int the database, only the gender column for this one is a blank and no longer a null.

            Does anyone know what is the right syntax here for me to insert the value in the database correctly?

            Thanks in advance.