FCehckBox Component

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:

Checkboxes do not “contain variables”, they have 2 states, checked (or true) and unchecked (or false).

You can use[AS]checkBox1.setChangeHandler(“myHandler”);
function myHandler(component) {
my_value = component._name+" = "+component.getValue();
trace(my_value);
}[/AS]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.

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?

myData.variablenameyouwant = my_value;

DUH, thanks eyezberg. You’re awesome too. :slight_smile:

Since I have 4 checkboxes, how do I write the code to differentiate which code is for which checkbox?

You can use the same handler for all checkboxes:[AS]myArray = [checkBox1, checkBox2];//store the checkboxes instance names here
for (var i in myArray) {
myArray*.setChangeHandler(“myHandler”);
}
function myHandler(component) {
my_value = component._name+" = "+component.getValue();
trace(my_value);
}[/AS]

claudio, now them I’m using an array, I can’t use this anymore. . .

[AS]
myData.myVariableName = my_value;
[/AS]

What do I use instread because I still need to give a variable to each checkbox?

ok here’s what I’ve got so far. . .
[AS]
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*.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”);
}
[/AS]

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?

somebody please help me! :frowning: