Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

how to get the name of radio button

Explorer ,
Aug 01, 2009 Aug 01, 2009

hopw to get the name of selected option button

var myRadioGroup:RadioButtonGroup=new RadioButtonGroup("options");

for (i=0; i<5; i++) {
    radio.group=myRadioGroup;
    radio.label="";
    radio.value=i;
    radio.move(10, int(int(55)+(105*y_counter)));
    myRadioGroup.addEventListener(Event.CHANGE, changeHandler);
               
    addChild(radio);
}

function changeHandler(event:Event):void
{
          var rbg:RadioButtonGroup = event.target as RadioButtonGroup;
          var rb:RadioButton = rbg.selection;
        //how to get the name of selected option button
}

TOPICS
ActionScript
783
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 01, 2009 Aug 01, 2009

iam not clear about what name u are asking because there is no property called "name"

anyway i think u are looking for this.

if u want the label(the option that u have selected) of the selected option then the below code will do it.

radiogroup1.selectedvalue.tostring();

if u want the id of the selected radio button the below code will do it.

radiogroup1.selection.tostring();

if this post answers your question then mark as such.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 01, 2009 Aug 01, 2009

i have to create 5 radio button with id or name 1to 5.

and on clicking of any radio button i want to know the name or id of that radio button  like 1 ,2

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 01, 2009 Aug 01, 2009

then this woud help

radiogroup.selection.tostring() will give u the name but along with the project name like the one below

projectname.radiobutton

if this answers please mark as such

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 01, 2009 Aug 01, 2009

i m not able to find the name  please tell me more how to do that .

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 02, 2009 Aug 02, 2009
LATEST

declare one string variable like

var str:String;

now assign the radiobutton name like this.

str=radiogroup.selection.tostring()

now str would contain the name of the button

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines