PDA

View Full Version : [AS2] Need to pass a yes or no value from radioButton to DB


somnamblst
06-22-2009, 08:17 PM
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 don't care as long as it can be interpreted to mean one thing or another.

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

//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. Thedata collect script is ASP.

steveh62
06-23-2009, 11:03 AM
try look at the following and run it and watch the output.
rgds
steve

/**
Requires:
- RadioButton component in library
*/

this.createClassObject(mx.controls.RadioButton, "my_rb", 10, {label:"first", groupName:"radioGroup"});

my_rb.data = "hello";
my_rb.label = "#FF00FF";
var rbListener:Object = new Object();
rbListener.click = function(evt_obj:Object){
trace("The data value for my_rb is " + my_rb.data);
}
// Add listener.
my_rb.addEventListener("click", rbListener);