3 Replies Latest reply on Nov 18, 2009 6:40 AM by Ned Murphy

    Help with mail form...

    Synnyzter1977

      Can someone please tell me why when I submit this form it gets stuck on the "sending" frame instead of advancing to the "acknowledge" frame as it should?  The code is found near the bottom...."if(this.sent == OK)" blah blah blah....  Been trying for hours now and im sure its something simple...

                 

       

       

       

      stop();

       

      //create an array
      var favarr:Array = new Array();

       

      //populate the combo box using the array budget box
      favarr.push({data:"", label: "select one"});
      favarr.push({data: "0 - $250", label:"0 - $250"});
      favarr.push({data: "$250 - $500", label:"$250 - $500"});
      favarr.push({data: "$500 - $1000", label:"$500 - $1000"});
      favarr.push({data: "$1000+", label:"$1000+"});
      // end budget box

       

      // services box start
      //create an array
      var favarr1:Array = new Array();

       

      //populate the combo box using the array
      favarr1.push({data:"", label: "select one"});
      favarr1.push({data: "Basic Website", label:"Basic Website"});
      favarr1.push({data: "Dynamic Site (Flash)", label:"Dynamic Site (Flash)"});
      favarr1.push({data: "eCommerce Site", label:"eCommerce Site"});
      favarr1.push({data: "Site Redesign", label:"Site Redesign"});
      favarr1.push({data: "Site Upgrade / Update", label:"Site Upgrade / Update"});
      favarr1.push({data: "Graphic / Logo Design", label:"Graphic / Logo Design"});
      favarr1.push({data: "Business Card Design", label:"Business Card Design"});
      favarr1.push({data: "Other", label:"Other"});

       


      services.dataProvider = favarr1;
      services.setSize(150, 20);
      // end services box

       

      budget.dataProvider = favarr;
      budget.setSize(150, 20);

       

      //create the form validation function
      function checkform():Boolean {
          var missing:Boolean = false;
         
          //validate name
          if(fname.text == "") {
              errortxt1.text = "Enter a name";
              missing = true;
          }
          else {
              errortxt1.text="";
          }
         
          //validate email
          if(address.text.indexOf("@") == -1) {
              errortxt2.text = "Enter an email";
              missing = true;
          }
          else {
              errortxt2.text=""
          }
             
         
          //validate details
          if(details.text == "") {
              errortxt3.text = "Enter details";
              missing = true;
          }
          else {
              errortxt1.text="";
          }
         
          //if missing is true return false
          return missing ? false : true
      }

       

      //create function that sends data
      function submitdata():Void {
          var formok:Boolean = checkform();
          var message:LoadVars = new LoadVars();
          var messageget:LoadVars = new LoadVars();
          var urlpath:String;
         
         
         
          if(formok) {
              message.fname = fname.text; //transfer variables to php this now results in $_POST['fname'];
              message.address = address.text; //transfer variables to php this now results in $_POST['address'];
              message.timeframe = timeframe.text; //transfer variables to php this now results in $_POST['timeframe'];
              message.budget = budget.selectedItem.data; //transfer variables to php this now results in $_POST['budget'];           
              message.services = services.selectedItem.data; //transfer variables to php this now results in $_POST['services'];
              message.detailsbox = detailsbox.text; //transfer variables to php this now results in $_POST['details'];

       

             
             
              message.sendAndLoad("mailscript.php?ck=" + new Date().getTime(), messageget); // send php code and send result back to flash. The ?ck=... bit is to ensure that the server does not send old data back instead of new data it is a cache killer parameter (ck) 
              gotoAndStop('sending');
             
              messageget.onLoad = function() {
                 
                  if(this.sent == OK) {
                  gotoAndStop('acknowledge');
                  }
                  else {
                      if(this.sent == failed) {
                          gotoAndStop('failure');
                          failuretxt.text = this.reason;
                      }
                  }       
              }
          }
      }

       


      backbtn.onPress = function():Void {
          gotoAndStop('theform');   
      }

       

      submitbtn.onPress = function():Void {
          submitdata();  

       

      }

        • 1. Re: Help with mail form...
          Ned Murphy Adobe Community Professional & MVP

          Unless OK is some variable that is defined somewhere that you aren't showing, it is otherwise a String and needs to be quoted...

           

          messageget.onLoad = function() {
                      if(this.sent == "OK") {
                      gotoAndStop('acknowledge');
                      }
                      else {
                          if(this.sent == failed) {
                              gotoAndStop('failure');
                              failuretxt.text = this.reason;
                          }
                      }       
                  }

           

          If that doesn't solve matters, try tracing the value of this.sent ahead of that if test... trace(this.sent);

          • 2. Re: Help with mail form...
            Synnyzter1977 Level 1

            Yeah it is in fact a variable and due to my sleep deprevation I overlooked it for 2 hours lol.  Thanks heh, guess I needed some fresh eyes.

            • 3. Re: Help with mail form...
              Ned Murphy Adobe Community Professional & MVP

              You're welcome