6 Replies Latest reply on Nov 25, 2007 6:18 PM by Newsgroup_User

    Form with Yes No Checkboxes

    Mary_Alice Level 1
      The checkbox result does not come to email...? I have spent many hours on this. Please HELP so I can complete the website. See script.
        • 1. Re: Form with Yes No Checkboxes
          Level 7
          Mary Alice,

          > The checkbox result does not come to email...?

          I started to reply in our other lengthy thread, but since you posted
          here, I'll reply here too.

          > my_lv.comments = this._parent.form_mc.comments_txt.text;

          In the text field example, you're referencing the TextField.text
          property of the text field with the instance name comments_txt. For your
          checkbox, you'll need to do practically the same thing -- only the CheckBox
          class doesn't feature a text property, and unfortunately it doesn't feature
          a getValue() method either. What it does support is a selected property.

          You'll need to add a corresponding property to your LoadVars instance
          just as you're doing for all the text fields.

          my_lv.checkbox1 = this._parent.form_mc.ch1.selected;

          See what's going on here? It's the same concept -- exactly the same.
          Assuming your check box has the instance name ch1, and assuming it resides
          inside form_mc along with the text fields, then what I just typed should do
          it.


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: Form with Yes No Checkboxes
            robdillon Most Valuable Participant
            Most of your form's content looks like it's in a clip named "form_mc". But the checkbox seems to be in a clip named "form". Is this correct, or could this be part of the problem?

            You may be able to solve the sending end of the problem by using:

            if (_parent.form_mc.ch1.getvalue() == false) {
            my_lv.ch1 = "no";
            } else {
            my_lv.ch1 = "yes";
            }

            If this part is correct, then you probably also need to change the php section for the check box to read:

            $checkbox .= "checkbox: " . $_POST["ch1"] ;

            or something like that.
            • 3. Re: Form with Yes No Checkboxes
              Mary_Alice Level 1
              Thanks. I plan to revise. BTW, What sort of 'actionscript' do I give the checkboxes. I am doing the Salt Form first because that only has two checkboxes, a yes and a no choice.

              Yes, they are both in the form layer. I have posted the script. The PHP I will now revise. Thanks. Waiting for your comment on the Actionscript.
              • 4. Re: Form with Yes No Checkboxes
                Mary_Alice Level 1
                BTW, do I name, give instance name to both the yes and no checkboxes: 'ch1' for each checkbox? Mary Alice

                • 5. Re: Form with Yes No Checkboxes
                  Mary_Alice Level 1
                  That is the Actionscript ----- my_lv.checkbox1 = this._parent.form_mc.ch1.selected; -----. I meant to say PHP. What script for the PHP?
                  • 6. Re: Form with Yes No Checkboxes
                    Level 7
                    Mary Alice,

                    >> I meant to say PHP. What script for the PHP?

                    The same as you've been using for everything else. If your ActionScript
                    is this:

                    my_lv.checkbox1 = this._parent.form_mc.ch1.selected;

                    ... it means you're sending a variable named checkbox1 along with all the
                    other variables. One of your earlier PHP variables corresponds to user
                    comments, and it references the POST variable like this:

                    $_POST["comments"]

                    What that does is pick up a variable sent by the LoadVars instance in
                    your SWF. The ActionScript looks like this:

                    my_lv.comments = this._parent.form_mc.comments_txt.text;

                    ... which means the LoadVars instance sends this: my_lv.comments --
                    $_POST["comments"] is what "hears" that on the PHP side. So if you're
                    sending a variable named checkbox1 from ActionScript, you likewise need to
                    "listen" for $_POST["checkbox1"] on the PHP side.

                    Same concept.

                    You could practically copy/paste a previous text field variable in
                    ActionScript and change the variable name, checkbox instance name, and make
                    it say "selected" instead of "text". You could then copy/paste a previous
                    line of PHP and change the variable name to suit.

                    > BTW, do I name, give instance name to both the yes and
                    > no checkboxes: 'ch1' for each checkbox?

                    You'll have to give a unique instance name to every checkbox. Perhaps
                    ch1 to the first one, ch2 to the second, and so on. If they're not uniquely
                    named, ActionScript wouldn't be able to tell them apart.


                    David Stiller
                    Adobe Community Expert
                    Dev blog, http://www.quip.net/blog/
                    "Luck is the residue of good design."