3 Replies Latest reply on Feb 25, 2008 11:35 AM by Media Post

    Email form using radio buttons

    Media Post
      Hello! I hope someone can help me out with this one!! I will start off by saying that I don't know too much about action script, but i have created a Flash email form with just text fields that has worked. Now I need to create a form with three sets of radio button groups. I need to pass the variables to a php email script. Can anyone guide me through this?

        • 1. Re: Email form using radio buttons
          robdillon Most Valuable Participant
          If you use loadVars sendAndLoad(), like in this example from the LiveDocs:

          var submitListener:Object = new Object();
          submitListener.click = function(evt:Object) {
          var result_lv:LoadVars = new LoadVars();
          result_lv.onLoad = function(success:Boolean) {
          if (success) {
          result_ta.text = result_lv.welcomeMessage;
          } else {
          result_ta.text = "Error connecting to server.";
          }
          };
          var send_lv:LoadVars = new LoadVars();
          send_lv.name = name_ti.text;
          send_lv.sendAndLoad(" http://www.flash-mx.com/mm/greeting.cfm", result_lv, "POST");
          };

          You can see that each item that you want to send will be set as a property of the send_lv LoadVars() object. You can add in the value of a radio button in a similar manner by setting another send_lv property:

          send_lv.radioOne = radiobuttonInstance.selection.data

          Or, you could use a function to evaluate the user selection and put that value into a variable, and then refer to that variable instead of radiobuttonInstance.selection.data
          • 2. Re: Email form using radio buttons
            Media Post Level 1
            THanks for you help Rob, but I still can't get it to work correctly. I'm not getting any email at all. I have a radio button group set up. The groupName is "Group1". Then there is a results text area on the screen with a var name of "results_ta". My email text area's var = "email_ti". I have a submit button component on the screen as well. The instance name is "submit_button". Below is the flash code that is on the first frame of my movie:

            var submitListener:Object = new Object();
            submitListener.click = function(evt:Object) {
            var result_lv:LoadVars = new LoadVars();
            result_lv.onLoad = function(success:Boolean) {
            if (success) {
            result_ta.text = result_lv.welcomeMessage;
            } else {
            result_ta.text = "Error connecting to server.";
            }
            };
            var send_lv:LoadVars = new LoadVars();
            send_lv.email = email_ti.text;
            send_lv.radioOne = group1.selection.data;
            send_lv.sendAndLoad("sendmail.php", result_lv, "POST");
            //send_lv.sendAndLoad("sendmail.php", "POST");
            };
            submit_button.addEventListener("click", submitListener);

            stop();


            Next my php code is as follows:

            <?php
            $sendTo = "christy@mediapostinc.com";
            $subject = "My Flash site reply";

            $headers = "From: " . $_POST["email"] ."\r\n";
            $headers .= "Reply-To: " . $_POST["email"] . "\r\n";

            $headers .= "Return-path: " . $_POST["email"];

            $message = $_POST["radioOne"];

            mail($sendTo, $from, $subject, $message, $headers);

            ?>



            Do you see anything that is off? I think I've lost it, because I had an email being sent, it just didn't add any of the info, but now I'm not even getting an email sent!! I'm in despair because the project is due tomorrow!!!
            thanks!
            • 3. Re: Email form using radio buttons
              Media Post Level 1
              How would I set up the later of your reply? To use a function to evaluate the user selection and put that value into a variable, and then refer to that variable instead of radiobuttonInstance.selection.data.

              thanks,
              Christy