# Help, need to pass data from a radio button

**URL:** <https://forum.kirupa.com/t/help-need-to-pass-data-from-a-radio-button/290944>\
**Category:** flash\
**Created:** [June 22, 2009, 3:25pm UTC](https://forum.kirupa.com/t/help-need-to-pass-data-from-a-radio-button/290944 "2009-06-22T15:25:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![somnamblst](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@somnamblst](https://forum.kirupa.com/u/somnamblst)\
**Post date:** [June 22, 2009, 3:25pm UTC](https://forum.kirupa.com/t/help-need-to-pass-data-from-a-radio-button/290944/1 "2009-06-22T15:25:07Z")

</div>

I have a data collect form that is passing name and email to a database. My fields are firstName, lastName. email and Optin. Optin is using the radioButton component and any value that could be interpreted as yes or no, true or false, 1 or 2 will work.

I actually have 2 isssues, though I set up a field called Optin in the data collect, trace is indicating that the field Optin is not registering.

I have been searching for examples that do something with a radioButton selection besides gotoAndPlay and have found nothing. I currently have this.

```auto
//Register each field to be collected
myForm.registerField("F1","firstName.text","String");
myForm.registerField("F2","lastName.text","String");
myForm.registerField("F3","email.text","Email");
myForm.registerField("F4","Optin.data","Data");

flashistListener = new Object();
flashistListener.click = function (evt){

  // Add your code here to test which radio is selected?
  // you can get this from evt.target.selection.data
  // find this by using:
  
  trace(evt.target.selection.data);   
  // i would then probably use:
  
  if(evt.target.selection.data == "Flashist"){
  
     //do something crazy
  }
  
  else if(evt.target.selection.data == "Anti-Flashist"){
     //do something crazier
  }
  
  //as many else ifs as you want
}

radioGroup.addEventListener("click", flashistListener);

```

My radio buttons have the instance name Optin, the data is Flashist and Anti-Flashist, the groupName is radioGroup
