5 Replies Latest reply on Jan 31, 2008 1:10 AM by Flash_Forms_Question

    capturing label selected in comboBox in a VAR, and POSTing it with a send button

    Flash_Forms_Question
      I've looked through the help many times and searched for various tutorials all over the net. Support docs I found have led to writing the following code (code was attached to comboBox instance) which was not working. The send button is not sending the label that I am trying to capture in the VAR "subject"

      on (change) {
      function(){
      subject = contactReason.getSelectedItem().label;
      }
      }

      I've been trying to look it up for a week and have had some headway - I didn't know how to use components at all before this. I'd asked for help or a specific tutorial but haven't found anything that will work the way I need it to.

      I tried changing my code to the following (code is attached to comboBox instance) after someone suggested something different - but it didn't work with my send button either.

      on (change) {
      var subject:String = contactReason.selectedLabel;
      }

      contactReason is the name of my comboBox instance...

      my send button POSTs to a CGI page that sends the info to an e-mail - using the VARs as subject etc (there are input boxes in form as well as the combobox) with the following code (code is attached to send button)...

      on (release) {
      loadMovieNum("formdone.swf", 2);
      recipient = "sean@pxlforge.com";
      loadVariablesNum("/cgi-bin/cgiemail/contact/contact.cgi", 0, "POST");
      }

      the input boxes still work fine and pass the other VARs, but I get no subject (I do if I use an input box - but not with comboBox)
        • 4. Re: capturing label selected in comboBox in a VAR, and POSTing it with a send button
          Flash_Forms_Question Level 1
          Thanks SOOOO much for helping!!!

          YAY! It took me a minute to figure out how to implement (I'm used to attaching scripts directly to buttons). But it works!!!! Mostly.

          Only one odd thing, I get 2 e-mails to me for a single click of the send button (also it looks like the form flashes twice - I see success screen for a splitsecond then the form again for a split second and then success screen stays up). I get one e-mail with the info from the comboBox and another e-mail with the word "undefined" where the label selection should be. The rest of the input info in the messages is identical.

          here is your code as implemented in my page... I changed "subject" to "reason" because I now use the subject line to sort the form replies to a designated folder in my e-mail program.

          // create a variable to hold the selection from the component...
          var subject:String;
          // create a listener to catch the selection...
          contactReason.addEventListener("change",showChange);
          // put the user's selection in the variable...
          function showChange() {
          reason = contactReason.selectedItem.label;
          }
          // the function for the send results button...
          sendButton.onRelease = function() {
          infoToSend = new LoadVars();
          // create a loadvars object to hold the info to be sent.
          serverResponse = new LoadVars();
          // a separate instance for the reply

          // change the references here as needed to match your form...
          infoToSend.realname = nameBox.text;
          infoToSend.email = mailBox.text;
          infoToSend.phone = phoneBox.text;
          infoToSend.details = detailBox.text;
          // use the value from the component here...
          infoToSend.reason = subject;
          infoToSend.recipient = "sean@pxlforge.com";
          // this function will deal with the server response...
          serverResponse.onLoad = function(success:Boolean) {
          if (success) {
          loadMovieNum("formdone.swf", 2);
          // do something
          } else {
          // do something else
          }
          };
          // send the data
          infoToSend.sendAndLoad("/cgi-bin/cgiemail/contact/contact.cgi",serverResponse,"POST");
          };


          and here is the code on my CGI page...


          To: [recipient]
          From: [email]
          Errors-To: sean@pxlforge.com
          Subject: pxlforge.com form submission


          Reason for Contact: [reason]
          Project Details: [details]
          Client Name: [realname]
          e-mail: [email]
          Phone: [phone]

          if anyone can spot what could be causing the double e-mails I'd appreciate it. But I am just so glad that Rob Dillon's suggestion actually passed the info properly!!!!!

          Thanks again!!!
          • 5. capturing label selected in comboBox in a VAR, and POSTing it with a send button
            Flash_Forms_Question Level 1
            I fixed it. I realized that I had forgotten to remove the following from my send button

            on (release) {
            loadMovieNum("formdone.swf", 2);
            recipient = "sean@pxlforge.com";
            loadVariablesNum("/cgi-bin/cgiemail/contact/contact.cgi", 0, "POST");
            }

            but once I did - I only got one e-mail - but it was the one that said "undefined" where the selected comboBox label should be. Apparently the correct e-mail i was getting was coming from my send button, not your script. So I took the send and success parts of your script out and put my loadVariablesNum script back on my send button and it works perfectly in conjunction with the way yours dealt with storing the selected comboBox label.

            I couldn't have done it without you.... thanks!!

            now all I have to do is figure out why the tutorial on customizing the comboBox elements isn't working for me. I was able to swap out an entirely new theme - but when i tried editing library elements of one and then applying THAT to my document - no change. I'll mess with it some more. I think I'm getting components a bit more than when i first tried. So thats next. Wish me luck!

            Thanks again!!!!! I really appreciate you taking the time to help scripting!