Hi there,
I working on a send a friend script and I am trying to ad a "yes I want to receive the newsletter" checkbox. I want to send a yes or no to sendfriend.php but it won't work? What is the problem?
PHP Code:
// SETTING VARIABLES
var bedanktBericht = '';
var errorBericht = '';
var fout1 = false;
var fout2 = false;
var fout3 = false;
var fout4 = false;
var fout5 = false;
var fout6 = false;
var signup:mx.controls.CheckBox;
scherm._visible = false;
// check ENTER
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.getCode() == Key.ENTER) {
checkData();
}
};
Key.addListener(keyListener);
// SET BUTTON
this.send.onPress = function() {
checkData();
};
// CHECK EMAIL
function emailCheck(address:String):Boolean {
if (address.indexOf("@")<0) {
return false;
} else {
return true;
}
}
// CHECK INPUT
function checkData() {
// FIELD 1 -------------- correct emailaddress needed
if (emailCheck(this.txt.email1.text) == true && this.txt.email1.text != "") {
email1 = this.txt.email1.text;
this.fout1.gotoAndPlay(6);
fout1 = false;
} else {
fout1 = true;
this.fout1.gotoAndPlay(1);
}
// FIELD 2 ------------------------------------------
if (this.txt.email2.text == "") {
fout2 = false;
this.fout2.gotoAndPlay(1);
//trace("niets ingevuld");
} else if (emailCheck(this.txt.email2.text) == false && this.txt.email2.text != "") {
fout2 = true;
this.fout2.gotoAndPlay(1);
//trace("geen geldig emailadres, maar wel wat ingevuld");
} else {
email2 = this.txt.email2.text;
this.fout2.gotoAndPlay(6);
fout2 = false;
//trace("goed");
}
// FIELD 3 ------------------------------------------
if (this.txt.email3.text == "") {
fout3 = false;
this.fout3.gotoAndPlay(1);
} else if (emailCheck(this.txt.email3.text) == false && this.txt.email3.text != "") {
fout3 = true;
this.fout3.gotoAndPlay(1);
} else {
email3 = this.txt.email3.text;
this.fout3.gotoAndPlay(6);
fout3 = false;
}
// FIELD 4 ------------------------------------------
if (this.txt.email4.text == "") {
fout4 = false;
this.fout4.gotoAndPlay(1);
} else if (emailCheck(this.txt.email4.text) == false && this.txt.email4.text != "") {
fout4 = true;
this.fout4.gotoAndPlay(1);
} else {
email4 = this.txt.email4.text;
this.fout4.gotoAndPlay(6);
fout4 = false;
}
// FIELD 5 ------------------------------------------
if (this.txt.email5.text == "") {
fout5 = false;
this.fout5.gotoAndPlay(1);
} else if (emailCheck(this.txt.email5.text) == false && this.txt.email5.text != "") {
fout5 = true;
this.fout5.gotoAndPlay(1);
} else {
email5 = this.txt.email5.text;
this.fout5.gotoAndPlay(6);
fout5 = false;
}
// FIELD 6 ------------------------------------------
if (this.txt.email6.text == "") {
fout6 = false;
this.fout6.gotoAndPlay(1);
} else if (emailCheck(this.txt.email6.text) == false && this.txt.email6.text != "") {
fout6 = true;
this.fout6.gotoAndPlay(1);
} else {
email6 = this.txt.email6.text;
this.fout6.gotoAndPlay(6);
fout6 = false;
}
// ALS ER GEEN FOUTEN ZIJN
//if (fout1 == false && fout2 == false && fout3 == false && fout4 == false && fout5 == false && fout6 == false) {
//sendData();
//}
//
// we give "myCheckbox" a default value
var myCheckbox:String;
myCheckbox = "yes";
//
// we create a listener for the checkbox to increase either number
var checkListener:Object = new Object();
checkListener.click = function() {
//
// here we let the user select
if (nieuwsbrief.selected) {
myCheckbox = "yes";
} else {
myCheckbox = "no";
}
};
// ALS ER GEEN FOUTEN ZIJN
if (fout1 == false && fout2 == false && fout3 == false && fout4 == false && fout5 == false && fout6 == false) {
sendData();
}
//
}
// VERZENDEN VAN DATA NAAR PHP
function sendData() {
scherm._visible = true;
this.output.text = 'Moment geduld...';
var sendData = new LoadVars();
sendData["_parent"] = this;
sendData.email1 = email1;
sendData.email2 = email2;
sendData.email3 = email3;
sendData.email4 = email4;
sendData.email5 = email5;
sendData.email6 = email6;
sendData.myCheckbox = nieuwsbrief;
// sendData.nieuwsbrief = nieuwsbrief;
sendData.sendAndLoad("sendfriend.php",sendData,"POST");
sendData.onLoad = function(success) {
this['_parent'].bedanktBericht = 'Bedankt voor het doorsturen!';
this['_parent'].gotoAndStop('bedankt');
};
}
stop();