Hi, I have been working on my portfolio website like forever. I am struggling with one problem that I can not solve for nothing. Can someone please help me. I don't know what I am doing wrong.
I have two checkboxes. When selected the selected checkbox will appear in mytxt.text box. This is how I am checking that everything is working. Instead of the selected checkbox showing up in mytxt.text result it show up true and false, false and true, and if both boxex are check true and true. I am trying to get the result of the one check box that is check and for it to dispay the name. Could someone please help? I will place the code below. I have tried everything I could think of. I know it is easier to make my checkboxes into radio buttons, but I really would like to have checkboxes.
My check boxes are name apple and orange
import fl.controls.*;
import fl.controls.RadioButtonGroup;
//This sets a group name for the radio button instances.
var myradioGroup:RadioButtonGroup = new RadioButtonGroup("RadioButtonGroup");
//This assigns the radio button instances to the radio group.
cRadio1.group = myradioGroup;
cRadio2.group = myradioGroup;
//Gives labels to the checkboxes.
applecb.label="Apple";
orangecb.label="Orange";
//Event listener for the checkboxes.
applecb.addEventListener(MouseEvent.CLICK, changelist);
orangecb.addEventListener(MouseEvent.CLICK, changelist);
function changelist(event:MouseEvent):void {
mytxt.text = "";
}
submit_btn.addEventListener(MouseEvent.CLICK, submitFunc);
var radBtns = [cRadio1,cRadio2];
var errorsNum = 0;
function submitFunc(e:MouseEvent)
{
var finalData = "";
var errorFlag = "Followings errors were found.\n";
if (name_txt.text == "")
{
errorsNum++;
errorFlag += errorsNum+". Enter ur name.\n";
}
if (email_txt.text == "")
{
errorsNum++;
errorFlag += errorsNum+". Enter ur email.\n";
}
if (mobile.text == "")
{
errorsNum++;
errorFlag += errorsNum+". Enter ur phone number.\n";
}
if (!myradioGroup.selection)
{
errorsNum++;
errorFlag += errorsNum+". Select ur gender.\n";
}
if (age.selectedIndex < 0)
{
errorsNum++;
errorFlag += errorsNum+". Select any of the course.\n";
}
{
if (applecb.selected == true) mytxt.appendText(applecb.label + "\n");
if (orangecb.selected == true) mytxt.appendText(orangecb.label + "\n");
}
if (message_txt.text == "")
{
errorsNum++;
errorFlag += errorsNum+". Enter ur message.\n";
}
if (errorsNum > 0)
{
mytxt.text = errorFlag;
errorFlag = "";
errorsNum = 0;
return false;
}
else
{
finalData += "Thank you "+name_txt.text+" for contacting me! I will call you at "+mobile.text+", "+"else I can mail you also at "+email_txt.text+" in "+applecb.selected+" response "+orangecb.selected+" of your message "+message_txt.text+"\n\n Your other information is, you're a "+myradioGroup.selection.value+" and is between "+age.value+"\nThanks";
mytxt.text = finalData;
}
}