7 Replies Latest reply on May 1, 2009 11:10 PM by kglad

    orderform loses values on extended timeline

    Tokerman

      I am trying to create an orderform - only 5 products in it

       

      the outcome works nice but I want to check if an email address is correct and than I loose the values.

       

      The form is made in 5 frames

       

      The first should say how to pay

      the second to fill in the order

      the third to fill in the adresss and email details

      than a process to check the email in PHP

      and when correct it should say - order send correct

      and when incorrect it should go back to frame 3

       

      the outcome is in frame 2 were its hidden underneath -  to 4 in the timeline but when I hit the sendbutton and it does the check the values are not there any more.

       

      Hope that anyone can put my nose in the right direction - 15 hours and I don't understand it why?

       

      this is the link where I test the stuff (without checking the email it works)

       

      http://www.abc-magasin.com/orderform6.swf

       


      //presistant reference to this movie's mail timeline:
      var mainTL:MovieClip = this;

       

      //start off with submit button dimmed
      submit_mc._alpha = 20;

       

      //create the LoadVars objects which will be used later
      //one to send the data...
      var dataSender:LoadVars = new LoadVars();

       

      //and one to recieve what comes back
      var dataReceiver:LoadVars = new LoadVars();

       

      /*
      create listener for Key Object
      this is just a U.I. thing - "wakes up" the submit button
      when all fields have at least some content
      */

       

      var formCheck:Object = new Object();
      formCheck.onKeyUp = function() {
          if (name_txt.text != '' &&
                  email_txt.text != '' &&
                  sendto_txt.text != '' &&
                  address_txt.text != '' &&
                  city_txt.text != '' &&
                  zipcode_txt.text != '' &&
                  country_txt.text != '') {
              //clear any alert messages
              alert_txt.text = '';
              //enable the submit button
              submit_mc._alpha = 100;
          } else {
              //remain disabled until all fields have content
              submit_mc._alpha = 20;
          }
      }

       


      Key.addListener(formCheck);

       

      /*#######SET STYLES FOR TEXT FIELDS#######*/

       

      var normal_border:Number = 0x00FF00;
      var focus_border:Number = 0xFFCC66;

      var normal_background:Number = 0x009900;
      var focus_background:Number = 0x00FF00;

      var normal_color:Number = 0x00FF00;
      var focus_color:Number = 0x006600;

       

      inputs=[name_txt,email_txt,sendto_txt,address_txt,city_txt,zipcode_txt,country_txt];

       

      /*
      a "for in" loop now iterates through each element in the "inputs" array
      and applies our "normal" formatting to each input text field
      */

       

      for( var elem in inputs) {
          inputs[elem].border = true;
          inputs[elem].borderColor = normal_border;
          inputs[elem].background = true;
          inputs[elem].backgroundColor = normal_background;
          inputs[elem].textColor = normal_color;

       

       


          inputs[elem].onSetFocus = function() {
              this.borderColor = focus_border;
              this.backgroundColor = focus_background;
              this.textColor = focus_color;
              }
          inputs[elem].onKillFocus = function() {
              this.borderColor = normal_border;
              this.backgroundColor = normal_background;
              this.textColor = normal_color;
          }
         
      }

       

      /*DEFINE SUBMIT BUTTON BEHAVIOR*/

       

      submit_mc.onRelease = function() {
          //final check to make sure fields are completed
          if (name_txt.text != '' &&
                  email_txt.text != '' &&
                  sendto_txt.text != '' &&
                  address_txt.text != '' &&
                  city_txt.text != '' &&
                  zipcode_txt.text != '' &&
                  country_txt.text != '') {
              alert_txt.text='';//clear any previous error messages or warnings
              //advance playhead to frame 3 - the "processing" message
              mainTL.play();
              //assign properties to LoadVars object created previously
              dataSender.name = name_txt.text;
              dataSender.email = email_txt.text;
              dataSender.sendto = sendto_txt.text;
              dataSender.address = address_txt.text;
              dataSender.city = city_txt.text;
              dataSender.zipcode = zipcode_txt.text;
              dataSender.country = country_txt.text;
              //callback function - how to handle what comes back
              dataReceiver.onLoad = function() {
                  if (this.response == "invalid") {
                      mainTL.gotoAndStop(3);
                      alert_txt.text = "* Please check the email address - it does not appear to be valid."
                  } else if (this.response == "passed") {
                      mainTL.gotoAndStop(6);
                  }
              }

       

              dataSender.sendAndLoad("processOrderform.php", dataReceiver, "POST");
          } else {
             
              alert_txt.text = "* Please fill in all the fields before submitting the form.";
          }
         
      }