Professional Web Applications Themes

Submitting form - Macromedia Flex General Discussion

Can i know whether any1 know hw to submit our form after validating to another form where we can get the input from the first page for .mxml?? And can we insert data into SQL database using .mxml...

  1. #1

    Default Submitting form

    Can i know whether any1 know hw to submit our form after validating to another form where we can get the input from the first page for .mxml??

    And can we insert data into SQL database using .mxml
    flexdummy Guest

  2. #2

    Default Re: Submitting form

    I do not quite understand your question.

    "Submit" is an html-world term and we do not really submit forms in Flex.
    Instead, we use a data service call to send the data to some middle tier
    application like JSP, Java, ASP.Net, CF, etc.

    Say what you want to do in some other words.

    Data is saved to a database by again using a call to a data service to send
    the data to a middle tier program which does the actual save.

    Tracy



    ntsiii Guest

  3. #3

    Default Re: Submitting form

    I just want to submit the code below to another page that can display what i
    type inside the textbox.My code is as shown below

    <?xml version="1.0" encoding="utf-8"?>

    <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">

    <mx:Model id="registration">
    <name>{name.text}</name>
    <email>{email.text}</email>
    <phone>{phone.text}</phone>
    <zip>{zip.text}</zip>
    <ssn>{ssn.text}</ssn>
    </mx:Model>

    <mx:EmailValidator field="registration.email"/>
    <mx:PhoneNumberValidator field="registration.phone"/>
    <mx:ZipCodeValidator field="registration.zip"/>
    <mx:SocialSecurityValidator field="registration.ssn"/>

    <mx:Form defaultAction="Form2.mxml" >
    <mx:FormItem label="Name" required="true">
    <mx:TextInput id="name" width="200"/>
    </mx:FormItem>

    <mx:FormItem label="Email" required="true">
    <mx:TextInput id="email" width="200"/>
    </mx:FormItem>

    <mx:FormItem label="Phone" required="true">
    <mx:TextInput id="phone" width="200"/>
    </mx:FormItem>

    <mx:FormItem label="Zip" required="true">
    <mx:TextInput id="zip" width="60"/>
    </mx:FormItem>

    <mx:FormItem label="Social Security" required="true">
    <mx:TextInput id="ssn" width="200"/>
    </mx:FormItem>

    <mx:FormItem>
    <mx:Button label="Place Order"
    click="mx.validators.Validator.isStructureValid(th is,'registration');"/>
    </mx:FormItem>

    </mx:Form>
    </mx:Application>


    flexdummy Guest

  4. #4

    Default Re: Submitting form

    We still have a terminology problem.

    We do not have "pages" in Flex. Try to explain again without using the words
    "submit" or "page".

    Do you want to display an order confirmation to the user? Do you want to
    display a different view?

    What is the business case here, I will try to help.

    Have you looked at the Flex samples?

    Tracy

    ntsiii Guest

  5. #5

    Default Re: Submitting form

    i just want 2 display the text that i have type not on the same place as the textbox
    flexdummy Guest

  6. #6

    Default Re: Submitting form

    Try this:
    Tracy


    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">
    <mx:Script><![CDATA[
    private function placeOrder(oEvent):Void
    {
    var bIsValid:Boolean =
    mx.validators.Validator.isStructureValid(this,'reg istration')
    var sConf:String = "";
    if (bIsValid) {
    sConf += "Name: " + registration.name;
    sConf += "\neMail: " + registration.email;
    sConf += "\nPhone: " + registration.phone;
    sConf += "\nZip: " + registration.zip;
    sConf += "\nSSN: " + registration.ssn;
    taOrderConf.text = sConf;
    }
    else {
    alert("Entries must be valid in order to order.");
    }

    }
    ]]></mx:Script>
    <mx:Model id="registration">
    <name>{name.text}</name>
    <email>{email.text}</email>
    <phone>{phone.text}</phone>
    <zip>{zip.text}</zip>
    <ssn>{ssn.text}</ssn>
    </mx:Model>
    <mx:EmailValidator field="registration.email"/>
    <mx:PhoneNumberValidator field="registration.phone"/>
    <mx:ZipCodeValidator field="registration.zip"/>
    <mx:SocialSecurityValidator field="registration.ssn"/>
    <mx:Form >
    <mx:FormItem label="Name" required="true">
    <mx:TextInput id="name" width="200"/>
    </mx:FormItem>
    <mx:FormItem label="Email" required="true">
    <mx:TextInput id="email" width="200"/>
    </mx:FormItem>
    <mx:FormItem label="Phone" required="true">
    <mx:TextInput id="phone" width="200"/>
    </mx:FormItem>
    <mx:FormItem label="Zip" required="true">
    <mx:TextInput id="zip" width="60"/>
    </mx:FormItem>
    <mx:FormItem label="Social Security" required="true">
    <mx:TextInput id="ssn" width="200"/>
    </mx:FormItem>
    <mx:FormItem>
    <mx:Button label="Place Order" click="placeOrder(event)"/>
    </mx:FormItem>
    </mx:Form>
    <mx:TextArea id="taOrderConf" width="200" height="200" />
    </mx:Application>

    ntsiii Guest

  7. #7

    Default Re: Submitting form

    Try this:
    Tracy


    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">
    <mx:Script><![CDATA[
    private function placeOrder(oEvent):Void
    {
    var bIsValid:Boolean =
    mx.validators.Validator.isStructureValid(this,'reg istration')
    var sConf:String = "";
    if (bIsValid) {
    sConf += "Name: " + registration.name;
    sConf += "\neMail: " + registration.email;
    sConf += "\nPhone: " + registration.phone;
    sConf += "\nZip: " + registration.zip;
    sConf += "\nSSN: " + registration.ssn;
    taOrderConf.text = sConf;
    }
    else {
    alert("Entries must be valid in order to order.");
    }

    }
    ]]></mx:Script>
    <mx:Model id="registration">
    <name>{name.text}</name>
    <email>{email.text}</email>
    <phone>{phone.text}</phone>
    <zip>{zip.text}</zip>
    <ssn>{ssn.text}</ssn>
    </mx:Model>
    <mx:EmailValidator field="registration.email"/>
    <mx:PhoneNumberValidator field="registration.phone"/>
    <mx:ZipCodeValidator field="registration.zip"/>
    <mx:SocialSecurityValidator field="registration.ssn"/>
    <mx:Form >
    <mx:FormItem label="Name" required="true">
    <mx:TextInput id="name" width="200"/>
    </mx:FormItem>
    <mx:FormItem label="Email" required="true">
    <mx:TextInput id="email" width="200"/>
    </mx:FormItem>
    <mx:FormItem label="Phone" required="true">
    <mx:TextInput id="phone" width="200"/>
    </mx:FormItem>
    <mx:FormItem label="Zip" required="true">
    <mx:TextInput id="zip" width="60"/>
    </mx:FormItem>
    <mx:FormItem label="Social Security" required="true">
    <mx:TextInput id="ssn" width="200"/>
    </mx:FormItem>
    <mx:FormItem>
    <mx:Button label="Place Order" click="placeOrder(event)"/>
    </mx:FormItem>
    </mx:Form>
    <mx:TextArea id="taOrderConf" width="200" height="200" />
    </mx:Application>

    ntsiii Guest

  8. #8

    Default Re: Submitting form

    How to use the HttpService?Bcoz my code below got error.Isit the httpservice
    can post input of user to another form?

    <?xml version="1.0"?>

    <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns="*">
    <mx:Script>

    <![CDATA[
    // Submit form is everything is valid.
    private function submitForm():Void {
    test.send();
    }
    ]]>

    </mx:Script>

    <mx:HTTPService id="test"
    url="http://localhost:8700/samples/forms/display.mxml" method="POST"
    showBusyCursor="True">

    <mx:request xmlns="">

    <test1>{test1.text}</test1>

    <test2>{test2.text}</test2>

    </mx:request>

    </mx:HTTPService>

    <mx:Form x="34" y="25">

    <mx:FormHeading label="Test Form"/>

    <mx:FormItem label="Test 1" id="test1_lbl">

    <mx:TextInput id="test1"/>

    </mx:FormItem>

    <mx:FormItem label="Test 2" id="test2_lbl">

    <mx:TextInput id="test2"/>

    </mx:FormItem>

    <mx:Button label="Submit" id="sub_btn"
    click="submitForm();" />

    </mx:Form>

    </mx:Application>

    flexdummy Guest

  9. #9

    Default Re: Submitting form

    Ya.i have try your code above but can i make the textarea to be in another .mxml(not in the same page with the textbox).btw thank alot
    flexdummy Guest

  10. #10

    Default Re: Submitting form

    Sorry for so many question.Coz i still have qns on storing this information into SQL database.
    flexdummy Guest

  11. #11

    Default Re: Submitting form

    Dear flexdummy,

    Sounds like you need to get the basics nailed down. Check out the Flex
    doentation and get yourself familiar with it.

    Basically, you have Flex which is the user interface (and an awesome one at
    that). You need some sort of scripting language and back-end. This is the
    middle-tier application which Tracy is talking about. You should already have
    this if you can work with databases in some other way? It can be an array of
    things from ColdFusion to Java to PHP to ASP, whatever -- it doesn't really
    matter that much.

    I'll help you out here, but you should get yourself familiar with Flex and how
    it works.

    In your example, you have a request parameter with different variables
    assigned to the text boxes on your page. This is not going to fly fully, though
    you are on the right track.

    Get rid of the xmlns = "" in your request param, it doesn't affect anything.

    Change your submitForm function to:

    private function submitForm():Void {

    private var RequestVars:Object = new Object();

    RequestVars.test1 = test1.text
    RequestVars.test2 = test2.text

    test.send(RequestVars);

    }

    Then on the back end, you handle the data like you would normally. Meaning you
    read in the request variables, p them as you please until your eyes turn
    green, write the data to a database, update your database whatever, at that
    point it's out of Flex land and into server-scripting land, whatever your
    language of choice may be. I am not going to go into that here.

    That's that. You can then pass back variables to Flex so that Flex can display
    some sort of notice to the end-user. Remember, it's all XML. So, the output
    would be something like:

    <response message="Operation successful!"/>

    And then you read that variable in by referring to
    test.result.response.message. (Where test refers to your HTTPService as you
    gave it the id of test).

    That should be pretty clear and you should be able to figure it out from
    there...

    - Taka


    takak Guest

  12. #12

    Default Re: Submitting form

    sorry takak i still don't get wat you mean can you show me the code of i
    textbox and pass in to another.mxml that display the input inside the
    textbox.As now i am struck with the above code as it couldn't pass the data to
    another .mxml

    Thank

    flexdummy Guest

  13. #13

    Default Re: Submitting form

    Help my codes still gt error
    flexdummy Guest

  14. #14

    Default Re: Submitting form

    Dear flexdummy,

    Sorry, it should be

    <mx:HTTPService id="test"
    url="http://localhost:8700/samples/forms/serve-side-page.jsp" method="POST">

    you tracking?

    You won't actually be redirected to the page. The data will be passed to the
    page. You would then p the data and output xml from that page. You would
    then read the response back in by using test.result as your data source.

    You tracking?

    takak Guest

  15. #15

    Default Re: Submitting form

    Hw i can p the data and output xml from that page. And then read the response back in by using test.result as your data source.

    flexdummy Guest

  16. #16

    Default Re: Submitting form

    Dear flexdummy,

    I want to help you out but now you're asking very simple questions.

    Do you know how to write ASP, JSP or PHP pages. You just simply read in the
    request variables. in PHP it's ($_REQUEST), p them, write them to a
    database, etc. whatever and then you run an echo statement like:

    "echo <response><message>Successful</message></response>"

    or if it's unsuccessful:

    "echo <response><message>Unsuccessful</message></response>"

    then you refer to it by using test.result.response.message.

    You should really get your misunderstoods cleared up on this subject and you
    should get yourself more familiar with Flex.

    Perhaps browse through some of the sample apps.

    takak Guest

  17. #17

    Default Re: Submitting form

    can i noe wher to put the echo...?Most importantly where to put the test.result... so that i could read them from ASP page?Can u provide sample code for me coz i so stupid
    flexdummy Guest

  18. #18

    Default Re: Submitting form

    My code below still gt error hw come??
    HTTPService Fault: Could not retrieve data
    My asp code is also shown below.Could some1 help?

    <?xml version="1.0"?>
    <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns="*">
    <mx:Script>
    <!]>
    </mx:Script>
    <mx:HTTPService id="test"
    url="http://localhost:8700/samples/forms/display.asp" method="POST">
    <mx:request>
    <test1>{test1.text}</test1>
    <test2>{test2.text}</test2>
    </mx:request>

    </mx:HTTPService>
    <mx:Form x="34" y="25">
    <mx:FormHeading label="Test Form"/>
    <mx:FormItem label="Test 1" id="test1_lbl">
    <mx:TextInput id="test1"/>
    </mx:FormItem>
    <mx:FormItem label="Test 2" id="test2_lbl">
    <mx:TextInput id="test2"/>
    </mx:FormItem>
    <mx:Button label="Submit" id="sub_btn" click="submitForm();" />
    </mx:Form>
    </mx:Application>

    ###########display.asp#########
    <%
    Dim stCatname, ststatus
    stCatname = request.form("test1")
    ststatus = request.form("test2")
    response.Write(test1)
    %>

    flexdummy Guest

Similar Threads

  1. after submitting form go to page . . . .
    By rmstvns in forum Macromedia Dynamic HTML
    Replies: 1
    Last Post: November 7th, 02:31 AM
  2. Replies: 0
    Last Post: April 19th, 06:53 AM
  3. Use PDf fill in form in Website and submitting form info.
    By Alexandre_L_Eveille@adobeforums.com in forum Adobe Acrobat Macintosh
    Replies: 0
    Last Post: August 3rd, 09:26 PM
  4. Submitting Form Var Problem
    By Ralph Freshour in forum PHP Development
    Replies: 1
    Last Post: October 31st, 02:27 AM
  5. Submitting form with a unique ID
    By James Brown in forum ASP.NET General
    Replies: 2
    Last Post: July 6th, 12:09 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139