5 Replies Latest reply on Sep 14, 2006 1:34 PM by Smasher987

    Form Problem

      Hello everyone. I just got flex and I'm having fun playing around with it. I was wondering How could I make a form to submit what the user put in it to an e-mail. I'll show you an example what I mean.
      The Form
        • 1. Re: Form Problem
          peterent Level 2
          I have to admit that I'm not terribly browser-savvy, so someone else may have a better idea.

          One approach would be to send your information to a server and have it send out the mail. I know that PHP for example, can do that. Using HTTPService you could build a URL with request parameters made from your form that triggers a PHP script to send the email.

          The other, browser approach - if this is a possible - would be to use the ExternalInterface class (look it up in the docs) which makes it easy for the Flash Player (where Flex SWFs run) to communicate with the browser and thus, JavaScript functions. Perhaps its possible to send the mail using JavaScript. But may be there are spamming-issues with that, I don't know.
          • 2. Re: Form Problem
            davidmedifit Level 1
            I may not be understanding you 100%, but are looking for a flex implementation of the form you showed us?

            • 3. Re: Form Problem
              Smasher987 Level 1

              Originally posted by: davidmedifit
              I may not be understanding you 100%, but are looking for a flex implementation of the form you showed us?


              Correct I would like that form to work in a flex program. Like when i click the submit button in flex it will do the same thing as it does with the normal HTML form
              • 4. Re: Form Problem
                davidmedifit Level 1
                I'm not sure what your flex expertize is, so forgive me if I am too basic. Basically, you want 2 things:
                1) A Flex app that has the form
                2) A backend, like a web service, that will accept the data

                I personally use ColdFusion for my back end, so I opened a web service on my server that would take 5 parameter (corresponding to your form), and update a DB with those values.

                The Flex application, at it's simplest will have a form (mx:form), with form items, (mx:formitem) and text input fields (mx:textInput) for each of the form fields.

                You'll need an <mx:webService>, which will call your backend web service that updates the DB, and pass it the form field values. You'll do this by binding (I'll give you some references at the end of this post).

                When you press the button, you won't submit the form, it's more like you'll send the web service.

                What you'll probably like to do, also, is remove the form, and display a confirmation number - you'll do that using states.

                I gave a presentation at my recent user group on something like this. Go to http://www.cfugitives.com/index.cfm?commentID=45 and at the bottom of the post you'll see demo files (a PDF and a ZIP). Take a look at the source, and you'll see how I handled form updates, sending web service values, and changing states.

                I hope I didn't reduce this to too basic a level - like I said, I don't know your Flex expertize. If I wasn't specific enough, and you have particular problems, feel free to write back, and I'll see what I can do.


                • 5. Re: Form Problem
                  Smasher987 Level 1
                  Thank you dave for your input youve given me an example to follow from

                  Thanks again