5 Replies Latest reply on Aug 25, 2007 1:14 PM by Greg Dove

    Checkbox Help

    SBiMedia

      I need help ASAP. Here's the problem. I have created a 2 page form in Flash Prof 8. I don't have any issues passing the TextField variables to php from either page 1 or page 2, but I can't seem to get the Checkbox values on page 1 to carry over to page 2 and be uploaded to the database when the submit button is triggered.

      My script is attached:

      on (release) {


      //loads variable and submits to .php page
      var my_lv:LoadVars = new LoadVars();

      my_lv.firstName = _level0.firstName;
      my_lv.lastName = _level0.lastName;
      my_lv.email = _level0.email;
      my_lv.zipcode = _level0.zipcode;
      my_lv.myVar1 = _level0.myVar1;
      my_lv.myVar2 = _level0.myVar2;


      mytmpvar = optIn_chBx1.selected;
      if (mytmpvar == true) {
      my_lv.myVar1 = true; }
      else {
      my_lv.myVar1 = false;
      }

      mytmpvar = optIn_chBx2.selected;
      if (mytmpvar == true) {
      my_lv.myVar2 = true; }
      else {
      my_lv.myVar2 = false;
      }



      my_lv.sendAndLoad("SubmitEntry.php", my_lv,"POST");
        • 1. Checkbox Help
          Greg Dove Level 4
          Its a little difficult to be sure what the issue might be without more information.

          your code could be shortened
          my_lv.myVar1 =optIn_chBx1.selected;
          my_lv.myVar2 =optIn_chBx2.selected;

          trace('my_lv.myVar1 is:'+my_lv.myVar1);
          check the trace output to see if it gives what you expect

          For the checkbox 'values' to carry on between two frames make sure that there is only one keyframe in the first frame on the layer that contains the checkboxes and that the second frame is not a new keyframe with a new 'instance' of each of the checkboxes... its difficult to be sure what is causing the problem beyond that suggestion with the information you have posted, sorry.
          • 2. Re: Checkbox Help
            SBiMedia Level 1
            This method works just fine as long as my checkboxes and my submit button reside on the same page. The variables are loaded and passed to the database. The issue is that this is a two page form. There are checkboxes on page one (Frame 1 on the timeline). As normal, the user inputs their name, etc. Clicks on the appropriate checkboxes and then clicks on the next button to go to page two (Frame 2) where there are more checkboxes (all CB's have unique names, etc). The user clicks on the appropriate check boxes and then clicks on the SUBMIT button (located on Frame 2 of the timeline). Using the event handler listed in this post, the data from both pages (Frame 1 & Frame 2) are supposed to be uploaded to the database. But....it's not working. Let's assume that "chBx1" is on Page 1 / Frame 1, and "chBx2" resides on page 2 / Frame 2, the same location as the SUBMIT button. The variable from "chBx2" is traces correctly, but "chBx1" traces as either Undefined or False (even when the checkbox has been selected.

            Hopefully, this explanation helps and I appreciate any help you may offer.
            • 3. Re: Checkbox Help
              Greg Dove Level 4
              Is there any way you can put your fla online. I'll take a look at it if you want.

              If chBx1 is in its own layer and is only in a keyframe on frame 1 of that layer and not duplicated on frame 2, then it should continue to maintain its state etc . But that's the same advice I gave earlier, just a little more specific for chBx1.

              If that's not the problem/cause then I'd probably need to see the fla to work it out. It is strange that you get 'undefined' ever, because that would indicate that the checkBox does not exist, if you're tracing chBx1.selected in frame 2. If a checkbox exists, then its selected property is defined - and is either true or false.

              The other thing that may be related is the fact that you're doing a sendAndLoad with my_lv also receiving the result of the load part of that. What is your php script returning to my_lv? And are you tracing for example my_lv.myVar1 after the sendAndLoad has received its result back into my_lv, overwriting what was there originally?

              I normally use two different LoadVars for sendAndLoad and have the second one receive the result.

              This doesn't seem like it would be the problem ... but I am afraid its difficult to tell with the information I have. To get further I'd need to see the fla I think.



              • 4. Checkbox Help
                SBiMedia Level 1
                I have uploaded the FLA file to my FTP server.

                ftp.sbimedia.com
                UN: NextPana
                PW: form

                cramer@sbimedia.com
                • 5. Re: Checkbox Help
                  Greg Dove Level 4
                  OK, I'll email it to you now.

                  You were redeclaring the LoadVars on frame 2. I just put the declaration in the main timeline on frame 1 and removed the declarations in the on release handlers. A couple of other minor changes, but I think that was the main one.