View Full Version : FCehckBox Component
tranism
August 22nd, 2003, 03:16 PM
I have 4 checkboxes. Each one needs to contain a variable. When the checkbox is selected, flash will send that variable to my server.
How would one write this.
Please help me
:bounce:
eyezberg
August 23rd, 2003, 04:37 AM
Checkboxes do not "contain variables", they have 2 states, checked (or true) and unchecked (or false).
claudio
August 23rd, 2003, 12:43 PM
You can usecheckBox1.setChangeHandler("myHandler");
function myHandler(component) {
my_value = component._name+" = "+component.getValue();
trace(my_value);
}This will prompt: "checkBox1 = true" or "checkBox1 = false"
and store the information on a variable called my_value. Then do whatever you want with that.
Hope it helps.
tranism
August 23rd, 2003, 06:32 PM
Claudio-thats awesome. I have another question now. Currently my sendAndLoad method sends information from a loadVars instance I've named <b>myData</b>. How do I include what you just gave me into the myData instance so sendAndLoad knows to send the checkbox information as well?
eyezberg
August 23rd, 2003, 06:37 PM
myData.variablenameyouwant = my_value;
tranism
August 23rd, 2003, 06:39 PM
DUH, thanks eyezberg. You're awesome too. :)
tranism
August 23rd, 2003, 06:59 PM
Since I have 4 checkboxes, how do I write the code to differentiate which code is for which checkbox?
claudio
August 23rd, 2003, 07:09 PM
You can use the same handler for all checkboxes:myArray = [checkBox1, checkBox2];//store the checkboxes instance names here
for (var i in myArray) {
myArray[i].setChangeHandler("myHandler");
}
function myHandler(component) {
my_value = component._name+" = "+component.getValue();
trace(my_value);
}
tranism
August 24th, 2003, 08:47 PM
claudio, now them I'm using an array, I can't use this anymore. . .
myData.myVariableName = my_value;
What do I use instread because I still need to give a variable to each checkbox?
tranism
August 25th, 2003, 06:55 PM
ok here's what I've got so far. . .
formData = new LoadVars();
formData.name = "";
formData.address = "";
formData.email = "";
formData.article1 = my_value;
formData.article2 = my_value;
formData.article3 = my_value;
formData.article4 = my_value;
myArray = [pants,jackets,skirts,signature];
for (var i in myArray) {
myArray[i].setChangeHandler("myHandler");
}
function myHandler (component) {
my_value = component._name+" = "+component.getValue();
trace(my_value);
}
function submit() {
formData.sendAndLoad("http://www.media1stop.com/fabriziogianni/store/mailinglist.php", "", "POST");
}
I'm supposed to get an email if it works. Everything works except the checkboxes. They don't appear to be sending the variables. What have I done wrong?
tranism
August 25th, 2003, 06:59 PM
somebody please help me! :(
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.