flash actionscript:
Does anyone have a sample script of how to send radio button info variables to a simple PHP script that will email me the results? I can get it to work with input text boxes, but not with radio buttons. Just need a sample of what the code on the submit button would look like. No validation is needed. I have a survey that uses radio buttons, and I can't get it to send the results to the PHP that emails me the results. Thanks.
for groupName equal to radioGroup you can use: lo = new Object(); lv = new LoadVars(); lo.click = function(evt_obj:Object) { lv.radioGroup = evt_obj.target.selection.data; // or use what ever lv.variableName you want }; radioGroup.addEventListener("click", lo); submitBtn.onPress = function() { lv.send("yourPHP.php", "POST"); };
Thanks! I will try that. Will this script work unchanged for input text boxes as well? Like if I had both radio and input boxes in the same survey. And, do I have to list all the radio groups in the survey? Like: lo = new Object(); lv = new LoadVars(); lo.click = function(evt_obj:Object) { lv.radioGroup = evt_obj.target.selection.data; lv.radioGroup2= evt_obj.target.selection.data; lv.radioGroup3 = evt_obj.target.selection.data; lv.radioGroup4= evt_obj.target.selection.data; }; radioGroup.addEventListener("click", lo); submitBtn.onPress = function() { lv.send("yourPHP.php", "POST"); };
you need to assign lo to be the listener for those other radioGroups and you need to assign variables and values to your input textfields, too. if you need more help, what's the instance names of your textfields and are they components?
The text fields I have are not components, just made a textbox and changed it to input text, then gave it a VAR name and no instance name. Did that for all the imput text boxes in my survey. I just do not know how to get the imput text boxes and all the radio buttons to all pass over to my PHP for that sends me the email. Some of the radio button group names I have are just the number of the question the question. Example of the radio group names are: 1gender, 2age, 3family Examples of the VAR names for imput text boxes are similar, but for one question with many imput text boxes it looks like: 6brand, 6product, 6store, 6address, 6city
objects in flash should not have an initial character equal to a number. you didn't list the variable names of your textfields but if they are something like tf1Var, tf2Var etc and they are on the same timeline as your code, you can use: lo= new Object(); lv = new LoadVars(); lo.click = function(evt_obj:Object) { lv.evt_obj.target.groupName = evt_obj.target.selection.data; }; gender.addEventListener("click", lo); age.addEventListener("click", lo); family.addEventListener("click", lo); submitBtn.onPress = function() { lv.tf1Var=tf1Var; lv.tf2Var=tf2Var; lv.tf3Var=tf3Var; lv.send("yourPHP.php", "POST"); };
ok, I thought I was home free with that last script, but something is still not working. It still will not send me an email with the results. Here is the code I have now. //This is the code on teh flash button. lo= new Object(); lv = new LoadVars(); lo.click = function(evt_obj:Object) { lv.evt_obj.target.groupName = evt_obj.target.selection.data; }; gender1.addEventListener("click", lo); age2.addEventListener("click", lo); family3.addEventListener("click", lo); income4.addEventListener("click", lo); ethnic5.addEventListener("click", lo); purchase7.addEventListener("click", lo); whyChoose8.addEventListener("click", lo); howOftenUse9.addEventListener("click", lo); wouldYouUse10.addEventListener("click", lo); wouldYouRec10.addEventListener("click", lo); haveYouRec11.addEventListener("click", lo); tables13.addEventListener("click", lo); chairs13.addEventListener("click", lo); fabricCushions13.addEventListener("click", lo); awnings13.addEventListener("click", lo); pergolas13.addEventListener("click", lo); patioUmbrella13.addEventListener("click", lo); outdoorFireplace13.addEventListener("click", lo); firepit13.addEventListener("click", lo); $barbecue13.addEventListener("click", lo); outdoorKitchen13.addEventListener("click", lo); fence13.addEventListener("click", lo); railing13.addEventListener("click", lo); planters13.addEventListener("click", lo); fountains13.addEventListener("click", lo); other13.addEventListener("click", lo); wood14.addEventListener("click", lo); plastic14.addEventListener("click", lo); metal14.addEventListener("click", lo); glass14.addEventListener("click", lo); wroughtIron14.addEventListener("click", lo); stainlessSteel14.addEventListener("click", lo); vinylFabric14.addEventListener("click", lo); concrete14 .addEventListener("click", lo); brick14.addEventListener("click", lo); compositeMaterial14.addEventListener("click", lo); cobblestone14.addEventListener("click", lo); rattan14.addEventListener("click", lo); notified16.addEventListener("click", lo); contact17.addEventListener("click", lo); submitBtn.onPress = function() { lv.brand6=brand6; lv.product6=product6; lv.dpStore6=dpStore6; lv.address6=address6; lv.city6=city6; lv.yesWho11=yesWho11; lv.name12=name12; lv.company12=company12; lv.title12=title12; lv.street12=street12; lv.city12=city12; lv.state12=state12; lv.zip12=zip12; lv.country12=country12; lv.phone12=phone12; lv.fax12=fax12; lv.email12=email12; lv.fax12=fax12; lv.otherBox13=otherBox13; lv.comments15=comments15; lv.send("form.php", "POST"); }; //This is the PHP form code I have. <? $to = "binx@ebinx.com"; $subjectbox = "Carrand Survey"; $gender1 ="$gender1\n\n"; $age2 ="$age2\n\n"; $family3 = "$family3\n\n"; $income4 = "$income4\n\n"; $ethnic5 = "$ethnic5\n\n"; $brand6 = "$brand6\n\n"; $product6 = "$product6\n\n"; $dpStore6 = "$dpStore6\n\n"; $address6 = "$address6\n\n"; $city6 = "$city6\n\n"; $purchase7 = "$purchase7\n\n"; $whyChoose8 = "$whyChoose8\n\n"; $howOftenUse9 = "$howOftenUse9\n\n"; $wouldYouUse10 = "$wouldYouUse10\n\n"; $wouldYouRec10 = "$wouldYouRec10\n\n"; $haveYouRec11 = "$haveYouRec11\n\n"; $yesWho11 = "$yesWho11\n\n"; $name12 = "$name12\n\n"; $company12 = "$company12\n\n"; $title12 = "$title12\n\n"; $street12 = "$street12\n\n"; $city12 = "$city12\n\n"; $state12 = "$state12\n\n"; $zip12 = "$zip12\n\n"; $country12 = "$country12\n\n"; $phone12 = "$phone12\n\n"; $fax12 = "$fax12\n\n"; $email12 = "$email12\n\n"; $tables13 = "$tables13" $chairs13 = "$chairs13" $fabricCushions13 = "$fabricCushions13" $awnings13 = "$awnings13" $pergolas13 = "$pergolas13" $patioUmbrella13 = "$patioUmbrella13" $outdoorFireplace13 = "$outdoorFireplace13" $firepit13 = "$firepit13" $barbecue13 = "$barbecue13" $outdoorKitchen13 = "$outdoorKitchen13" $fence13 = "$fence13" $railing13 = "$railing13" $planters13 = "$planters13" $fountains13 = "$fountains13" $other13 = "$other13" $otherBox13 = "$otherBox13" $wood14 = "$wood14" $plastic14 = "$plastic14" $metal14 = "$metal14" $glass14 = "$glass14" $wroughtIron14 = "$wroughtIron14" $stainlessSteel14 = "$stainlessSteel14" $vinylFabric14 = "$vinylFabric14" $concrete14 = "$concrete14" $brick14 = "$brick14" $compositeMaterial14 = "$compositeMaterial14" $cobblestone14 = "$cobblestone14" $rattan14 = "$rattan14" $comments15 = "$comment13\n\n"; $notified16 = "$notified14\n\n"; $contact17 = "$contact15\n\n"); $survey = "1. Gender: $1gender /n/n 2. Age: $age2 /n/n 3. Family Size: $family3 /n/n 4. Income: $income4 /n/n 5. Ethnic: $ethnic5 /n/n 6. General Purchase Information /n Brand: $brand6 /n Product: $product6 /n Store: $dpStore6 /n Address: $address6 /n City: $city6 /n/n 7. $name12 purchased product at: $purchase7 /n/n 8. $name12 chose Carrand because of $whyChoose8 /n/n 9. $name12 uses the products $howOftenUse9 /n/n 10. $name12 would use again: $wouldYouUse10 /n $name12 Would recommend: $wouldYouRec10 /n/n 11. $name12 recommended our products? $haveYouRec11 to $yesWho11 /n/n 12. Contact Info: /n Name: $name12 /n Company: $company12 /n Title: $title12 /n Street: $street12 /n City: $city12 /n State: $state12 /n Zip: $zip12 /n Country: $country12 /n Phone: $phone12 /n Fax: $fax12 /n Email: $email12 /n/n 13. $name12 owns these outdoor furnishings. /n $tables13 $chairs13 $fabricCushions13 $awnings13 $pergolas13 $patioUmbrella13 $outdoorFireplace13 $firepit13 $barbecue13 $outdoorKitchen13 $fence13 $railing13 $planters13 $fountains13 $other13 $otherBox13 /n/n 14. $name12 has these materials that are used in their outdoor living space. /n $wood14 $plastic14 $metal14 $glass14 $wroughtIron14 $stainlessSteel14 $vinylFabric14 $concrete14 $brick14 $compositeMaterial14 $cobblestone14 $rattan14 /n/n 15. $name12 had these Comments: /n $comments15 /n/n 16. Should we notify $name12 on new products? $notified16 /n/n 17. If $name12 wants to be notified, $contact17 is the best way. /n"; mail($to, $subjectBox, $survey, "From: $email12\nReply-To: $email12\n"); ?>
i don't see a problem with your flash code. you should start debugging by removing (or commenting out) large chunks of the unneeded variables in your php script to see what's incorrectly formatted or undefined.
Don't see what you're looking for? Try a search.
|