19 Replies Latest reply on Dec 23, 2007 1:45 PM by Greg Dove

    Problem with my email form

    Dave.Hollings
      Hi all,

      I have run into a small issue and cannot see what is causing my email form not to work. I have done this a few times now and have copied the actionscript I have working currently however the it still does not work. The form can be view live here and the flash file can be downloaded from here.

      I have attached the code for my flash form below and if anyone requires the code for my email.cfm page (this is the page that processes and sends the emails) then please let me know. I would appreciate any help I can get with this and I have been working on this for a couple of days now and have re-written the code about 6 times - it's starting to do my head in.

      Thank you in advance.

        • 1. Re: Problem with my email form
          Greg Dove Level 4
          At the moment your send button is not triggering the event based code to perform the sendAndLoad.

          It appears as if you are using a component button
          So you need to change the event handling code to be more like the combo box code.

          So not this:
          send_btn.onRelease = function

          but more like:

          clickListener = new Object();
          clickListener.click= function() { //same as the old onRelease handler

          //and further down...
          send_btn.addEventListener("click", clickListener);
          • 2. Re: Problem with my email form
            Dave.Hollings Level 1
            Thanks for your input and I see what you are saying, however after changing the code as suggested the button still does not action the code. The weird thing is as far as I am concerned if it executing the code to a certian point but no further. I'll try and explain:

            Within the button function (clickListener) there is are some if and else if statements checking to ensure the user has populated the required form fields, when the user clicks the send button and flash detects that a certain required field is undefined or blank then an alert box is shown with a relating message e.g. user clicks send without populating the comments field the app will display an alert box with 'Please provide details of your enquiry' message.

            This is working correctly however when all fields are completed as required and the user clicks the send button nothing happens. The app should display another alert box either stating that the enquiry has been sent and a copy has been sent to the email address provided, or an error in sending the email was detected.

            This comes from the email.cfm page. The code within the cfm page is basically a cfmail tag with a if / else statement which should send back to flash a true or false message. Flash then should determine that true equals success and false equals unsucessful and run the relative action as describe above.

            Any other suggestions? Does the code I posted look correct? I have provided the code once again with the amendments that you suggested - and thank you I appreciate the help.


            • 3. Re: Problem with my email form
              Greg Dove Level 4
              Sorry I'm just dealing with things as I see them rather than going through all of your code. That's got something working now... It's actually sending the data. And seemed to be working correctly when I just tested it.


              • 4. Re: Problem with my email form
                Greg Dove Level 4
                FYI your cfm script seems to throw an error on line 46 if the phone number is not submitted.
                • 5. Re: Problem with my email form
                  Dave.Hollings Level 1
                  Thanks for your assistance once again however after anaylising the code yet again I noticed a few minor errors, well missing syntax:

                  I had not declared the _loc3 as new LoadVars e.g.
                  var _loc3:LoadVars

                  I had also not declared _loc2 as new LoadVars e.g.:
                  var _loc2:LoadVars = new LoadVars();

                  Although this does make it appear to work by this I mean now I am getting the alert box come up once the user has completed the required fields and clicked the send button, but I keep getting the error message not the enquiry sent confirmation message. I would assume this is down to the email.cfm page not completing it's code correctly or not passing the correct true or false variable across back to flash. Any ideas?
                  • 6. Re: Problem with my email form
                    Greg Dove Level 4
                    At the moment your script is returning an error message complaining that CONTACTNUM is undefined . Perhaps you have named it telehphone in flash and its CONTACTNUM in your CFM script


                    comments=Testing%20from%20adobe%20forum&subject=Web%20Site%20Comments&telephone=&email=spa mfree%2Edove%40gmail%2Ecom&fullname=GWD
                    • 7. Re: Problem with my email form
                      Dave.Hollings Level 1
                      Not sure how you managed to find that but many thanks - as soon as I looked at the email.cfm code again (line 46) as you mentioned I realised contactnum is not a variable 'telephone' is. The same is true for line (59) for Form.enquiry should be 'comments'. Both of these are repeated further down on lines 105 and 114 respectively.

                      Just corrected the code but still no luck!
                      • 8. Re: Problem with my email form
                        Greg Dove Level 4
                        FYI:
                        the difference between
                        var _loc3 = new LoadVars();

                        and
                        var _loc3:LoadVars = new LoadVars();

                        is nothing in terms of the generated bytecode.

                        But it is a best practice. It enables code hinting and type checking etc.
                        • 9. Re: Problem with my email form
                          Greg Dove Level 4
                          Hmmm I got this in my email:

                          This is an automated email response from Whole New World.
                          Many thanks for your interest in Whole New World and our products, we hope you managed to find the information you were looking for. You are receiving this email as confimation of an enquiry we have just received. Our dedicated staff will be in touch within 36 hours of receiving your enquiry and hope to speak to you soon.

                          And I got a confirmation message
                          • 10. Re: Problem with my email form
                            Dave.Hollings Level 1
                            Well not sure what I have done but I tested the new code and it still did not work, however waited for about 10 minutes and got an email from yourself so I tested from here and it's all working fine very thing is working as it should.

                            Can't thank you enough it has been a pleasure talking to you and thanks, you are a real asset to this forum and people like myself.

                            Kind regards - David
                            • 11. Re: Problem with my email form
                              Greg Dove Level 4
                              But your script response is still not well formed from the server.

                              It should be straight text like:

                              &result=true;

                              (which is what you're aiming to do)

                              But instead its prefixing some css info and wrapping in a body tag
                              • 12. Re: Problem with my email form
                                Dave.Hollings Level 1
                                That email you got is part of the email coding it's just confirmation that your enquiry has been sent.
                                • 13. Re: Problem with my email form
                                  Greg Dove Level 4
                                  Your server response looks like the following instead of just

                                  &result=true
                                  • 14. Problem with my email form
                                    Greg Dove Level 4
                                    no it wasn't the email I was referring to.. its the response to the sendAndLoad in flash
                                    • 15. Re: Problem with my email form
                                      Dave.Hollings Level 1
                                      I see what you mean however it's working so I am reluctant to mess around with this code. Unless you have any suggestions on how to do this quickly without messing the layout of the email. The CSS code is basically for the email formatting that Whole New World (my clients) will receive and the end user (customers) receives.
                                      • 16. Re: Problem with my email form
                                        Greg Dove Level 4
                                        And thanks for the nice comments BTW. Happy to help.
                                        • 17. Re: Problem with my email form
                                          Greg Dove Level 4
                                          I've always sent back the LoadVars response as urlencoded name/value pairs same as how its sent to the server... I don't think it would make sense to do intentionally otherwise. Perhaps flash filters out the other stuff in your case if its working...seems unusual though. If you're happy that its working then that's fine...I guess.
                                          • 18. Re: Problem with my email form
                                            Dave.Hollings Level 1
                                            I'm back with one more question (sorry) - After getting this to work using cfm email processing a thought crossed my mind about other server side scripts. I have asked my client if they wish me to host their new site however I have not heard anything. I can host ColdFusion, php and a multitude of other scripts however their current hosting package I am unaware of. So I was wondering if you might know how I could change my email.cfm page into another scripting language providing similar results for example a email to both my clients and their customers formatted in html? I have no knowledge whatsoever outside of CF.

                                            Thanks and look forward to your comments / suggestions.
                                            • 19. Re: Problem with my email form
                                              Greg Dove Level 4
                                              I'm pretty sure there are a number of php examples in the forum here. It seems to be a frequent question, although one I don't think I have answered personally.
                                              I'm guessing it probably wouldn't be too difficult to find a php example here or elsewhere online, but yes you would need to get familiar with the other scripting language enough to be able to port your cfm script.