PDA

View Full Version : using the checkbox component w. MX


greenplasticcup
04-09-2002, 08:56 PM
I'm struggling with trying to send the value of a checkbox component to a php script. It picks up the text from a couple input text areas just fine, but nothing from my checkbox.

This is what I have for my submit button:

on (release) {
loadVariablesNum("emailform.php", "0", "POST");
gotoAndStop(2);
}


I've tried lots of additions to this and other frames and the component itself, but nothing seems to work. Can anybody help me find the way to send the value of the checkbox along with it? I'd be happy to build my own checkbox if that's what I need to, but I wouldn't know what to do with it when I get it built.

thanks a ton.

Jesse
04-10-2002, 02:01 AM
LoadVariables will only send the variables on the timeline it's executed on. I remember from my one experiment with Flash 5 check boxes that they used local variables rather than adapting variables on the _root level. You'll have to ensure the variables are all being established on the same timeline (whether it's _root or another child) and run your load action from there.

greenplasticcup
04-10-2002, 03:15 PM
I want to do that, I just dont know how. I've tried a few things but I feel like I'm shooting in the dark.

So you know what it looks like, I have an MC with a couple text input fields, the checkbox (maybe a few more checkboxes if I get it working) and a submit button.

I've tried various things along this line (on the submit button):

on (release) {
myVariable.getValue();
loadVariablesNum("emailform.php", "0", "POST");
gotoAndStop(2);
}

the name myVariable is the instance of the checkbox component. Nothing to any avail.

What am I missing?

Dravana
04-10-2002, 11:22 PM
http://www.macromedia.com/support/flash/applications/creating_forms/

has a tutorial how to make a form in MX with MX components

thellama
04-11-2002, 08:52 AM
Hello,

I'm trying to do the same thing, with no avail!!!! how do i capture the onstate of a check box and sent that as a variable to my perl script. The macromedia "tuturorial" left me even more confused!!!

Has it got something to do with the change handler (whatever that is)???? If so what?

I'm sure things were a lot simplier when I was a lad!!!! (well flash 5 anyway)

If anybody can help I will appreciate it!!!

Thanks in advance

Steve

Dravana
04-11-2002, 02:16 PM
just goto the site and read through the steps

it will become clear

greenplasticcup
04-11-2002, 03:11 PM
it looks like that tutorial is just for cold fusion and asp server-side scripts isn't it?

Dravana
04-12-2002, 07:54 AM
no it has a bit on that but you can take bits of the coding and use it to your own uses

that is what i have done

thellama
04-12-2002, 08:39 AM
erm...not exactly clear though is it?

can someone explain what a change handlet is and how I can use it to pass variables? Pllllleeeeeeaaaaassssseeeeee!!!

Thanks in advance

steve

skandibal
04-12-2002, 01:56 PM
I made a flash interface that receives records from mySQL and PHP.

I just wrote a function getRecords() in the _root which collects some variabels in flash and post them to PHP. I then uses load variables to recieve some values from PHP.

Make sure PHP returns a variable like this:
<?

// set variable value
list="the records retrieved from a mySQL db or any other value I want to retrieve";

//echo the value
print "&list=". urlencode($list) . "&";
?>

In my _root I have a dynamic textfield named "list".
After I call the function getRecords(); the "list "textfield now gets update from PHP.

Hope this helps. It shouldn't be to hard to get the value from a select box....

Cota
04-16-2002, 03:16 AM
Hey, I'm still working with flash mx, the help info gets rather confusing, but from the way I undertsand it, the change handler is used to call a function, be it custom or what have you. lets say you have a checkbox, when it is checked it might cause some info to be displayed somewhere, when its unchecked, that info will disappear. To do that you need to write a function, the change handler is where you would call that function. I could be wrong, like I said, thats just how I understand it. The tutorials at the macromedia site will really help to understand what does what...


As for greenplasticcup's issue, you're using myvariable.getvalue();
its getting the value but you arent sending it anywhere. You would have to use SomeVariable = componentname.getValue();
assuming they are all in the same time line. Its the same as using a Radio Button, but instead of componentName you would use the radiobutton group name.

Like I said, I could be wrong, but its working for me. Hope this helps

greenplasticcup
04-16-2002, 04:11 PM
cota, you are a lifesaver! Your simple explanation was exactly what I needed to know.

I added a change handler to the checkbox, which referenced a function that got the variable like you said. Easy as pie. :)

thanks again, I'm indebted to you.

trippin
08-04-2004, 05:15 AM
I've read the article and tried over and over it just wont work ... well first of all in flash I don't even see "change handler" in the properties list it's not there for any of my checkbox components ... so i've tried using

function radioDisplay (component) {
radioSize = component.getValue() ;
}
// We assign this function to the group gender
size.setChangeHandler("radioDisplay") ;

where 'size' is the name of my radio group (i've used the same just replacing the size with name of my checkboxes) ... no matter it didn't give any output in my php mailed form.... while textfields work no problems , radio and checkboxes wont ?? can anyone exactly write the code that allows the php script to pick it up as $variable ???

cheers

memphix
08-04-2004, 06:36 AM
a tutorial on forms for this site sounds very appropriate right now. :) if anyone does, i'd be keen to see it.

jsam
08-04-2004, 11:02 AM
Hello,
i can't understand what ur looking for.
But i attached .fla . see the file...

Jsam.

HoustonMatrix
05-18-2005, 08:09 AM
My form is basic. Name, Email , Subject, and Comments. I want to add 3 radio buttons or checkboxes (whichever is easier) to the form (which is all in the same frame) and have it post the info to my contact.php form which obviously then forwards the info to my email.

trippin
03-11-2006, 01:56 AM
Checkboxes ....

you need to set it first default state

checkBox1="No";

then

/assign values
myCheckboxListener = new Object();
myCheckboxListener.click = function (eventObject)
{
//if checkbox selected assign value yes
if (check1.selected)
{ checkBox1 = check1.getValue() ? "No" : "Yes";}
else
//if checkbox deselected assign value no
{ checkBox1 = check1.getValue() ? "Yes" : "No"; }
//etc ....
}
//then add listeners
check1.addEventListener("click", myCheckboxListener);
check2.addEventListener("click", myCheckboxListener);

//------------------------------------------------------
//for radios ... se value first
//all radio groups mus have same group name for example "myRadios"
//and all must have instance name eg. "radio1", "radio2"
radio1.setData("BlueHair");
radio2.setData("BlackHair");

then..

//change handler function that gets state
function getRadio() {
// this grabs selected value in the group myRadios only
//so it can be only BlueHair or BlackHair ...
myGrabbedValue = myRadios.getValue();
}

//attach handler functions to radio groups
myRadios.setChangeHandler("getRadio");

you can then grab the value in php using
$myRadios ... or $check1, $check2 etc

that's it .... no more

Design2Conquer
06-22-2006, 07:07 PM
Checkboxes ....

you need to set it first default state

checkBox1="No";

then

/assign values
myCheckboxListener = new Object();
myCheckboxListener.click = function (eventObject)
{
//if checkbox selected assign value yes
if (check1.selected)
{ checkBox1 = check1.getValue() ? "No" : "Yes";}
else
//if checkbox deselected assign value no
{ checkBox1 = check1.getValue() ? "Yes" : "No"; }
//etc ....
}
//then add listeners
check1.addEventListener("click", myCheckboxListener);
check2.addEventListener("click", myCheckboxListener);

//------------------------------------------------------
//for radios ... se value first
//all radio groups mus have same group name for example "myRadios"
//and all must have instance name eg. "radio1", "radio2"
radio1.setData("BlueHair");
radio2.setData("BlackHair");

then..

//change handler function that gets state
function getRadio() {
// this grabs selected value in the group myRadios only
//so it can be only BlueHair or BlackHair ...
myGrabbedValue = myRadios.getValue();
}

//attach handler functions to radio groups
myRadios.setChangeHandler("getRadio");

you can then grab the value in php using
$myRadios ... or $check1, $check2 etc

that's it .... no more


I have form with 3 checkboxes for an event. I put this code on the first frame. Is there another piece of code to add to the SUBMIT button when sending the form which includes input text and checkboxes??
other than:

on (release) {
if (form.name eq "" or form.message eq "" or form.email eq "") {
stop();
} else {
form.loadVariables("form.php", 0, "POST");
}
}

☻esign2Conquer

Cota
06-22-2006, 07:29 PM
WoW....an old thread to dig up...

Design2Conquer
06-22-2006, 07:36 PM
WoW....an old thread to dig up...


Yea, so....
at least I am searching posts b4 posting repeats, right??
:rolleyes:

Cota
06-22-2006, 07:43 PM
I cant argue with that.