View Full Version : checkbox variable
handepora
10-23-2003, 03:05 PM
Hi there
I'm making a flash form with several text fields, checkboxes and radiobuttons.
I have the following action in my submit button:
getURL("http://forms.melodysoft.com", "", "POST");
...what means that I'm sending my data to a "form mailer", if that is important.
OK. The text fields work perfect, the variables are sent to the server and all that, but I'm having a pain to make the checkboxes and radiobuttons to pass a variable, having little or none idea about actionscript as I have.
How do I give a checkbox a variable that tells if it is checked or not?
I'm sure a lot of people have faced this problem more than once.
Any help will be aprecciated.
hangalot
10-27-2003, 10:28 AM
eh. getURL sending variables in a post packet, kinda a scary thought for me since it is a GET... but anyway look inot the loadVars object that would b handy 4 u i think.
handepora
10-27-2003, 01:58 PM
Thanks for your reply. I got this thing solved in the flashkit forum anyway.
The following information was very helpful to me, so I share it in case someone browse this thread in the future:
-------------------------------------------------------------------------------
Here is the deal. When your visitor presses the send button the ActionScript needs to gather info from the Radiobuttons and Checkboxes, but not from the text boxes. The info then needs to be passed to a variable. Then when your getURL statement runs it will POST the contents of these varibles along with the text box variables. The text boxes pass their info to a variable the minute a visitor types the info in. This is most likely what is causing your problem.
On your SEND button you need to define a variable for your each of your CheckBoxes and one Variable for each of your RadioButton groups. A RadioButton group is just that, a group of buttons that are of the same subject.
Now the details. Click on your radio buttons, and under Properties and Parameters, give a name to "GROUP NAME". Then assign names to the LABEL and DATA fields. The DATA is what will be passed to your variable.
On your send button you will type the following:
myvar = radiobuttongroupname.getValue();
"myvar" is your variable and "radiobuttongroupname" is the GROUP NAME you gave to the Radio Buttons. Now treat "myvar" as you did the variables for the text fields.
For the CheckBoxes, you will have to edit LABEL and INSTANCE NAME.
On your send button you will type the following:
mytmpvar = instancename.getvalue();
if (mytmpvar == true) {
myvar = instancename.getLabel(); }
else {
delete myvar;
}
"mytmpvar" is a temp variable. DO NOTHING WITH IT.
"myvar" is your variable and "instancename" is the INSTANCE NAME you gave your CheckBox. This "IF THEN" statement checks the state of the CheckBox to see if it is checked. If it IS, the LABEL of the CheckBox is passed to "myvar". If the CheckBox is NOT checked, "myvar" is cleared, so it will return nothing.
Repeat the above ActionScript for all CheckBoxes. Make sure to give different INSTANCE NAMES and LABELS to each Checkbox you use.
Just in case you plan to use Comboboxes, you will type the following on your send button:
myvar = instancename.getSelectedItem().data;
"myvar" is your variable and "instancename" is the INSTANCE NAME you gave your ComboBox. This actionscript will return just the DATA that is entered in the Combobox Parameters.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.