rePOST form data without using GET

Discussion in 'ASP General' started by lbolognini@gmail.com, Feb 24, 2006.

  1. Guest

    Hi all,

    I was wondering if there's a technique to use POST instead of GET to
    send data back to a form so to refill it with user input after this
    hasn't passed validation.

    Any clues?

    Thanks,
    Lorenzo
    , Feb 24, 2006
    #1
    1. Advertising

  2. dNagel Guest

    it all depends... Do you want to do the validation client side or
    server side? If you do it client side, in JS you can return false
    in the onsubmit event of the form which will prevent the form from
    actually being submitted. If it has to be done on the server side,
    then you should investigate using a hash table to store field name/
    value pairs. JSON is a data definition language that should be of
    interest to you here... You could bundle all the form data into a
    single object and pass that back to the form and repopulate all of
    the fields quickly in the onload of the window.

    some useful links..

    Information about JSON

    http://www.json.org/

    Information about Prototype. This should make dealing with your forms
    a bit easier... think of the power you have with the ability to hit the
    server and process the response without refreshing the whole page.

    http://prototype.conio.net/
    http://www.sergiopereira.com/articles/prototype.js.html

    This library builds on prototype.js by letting you use CSS Selectors to
    assign methods to your elements.

    http://bennolan.com/behaviour/

    D.
    dNagel, Feb 24, 2006
    #2
    1. Advertising

  3. Paxton Guest

    wrote:
    > Hi all,
    >
    > I was wondering if there's a technique to use POST instead of GET to
    > send data back to a form so to refill it with user input after this
    > hasn't passed validation.
    >
    > Any clues?
    >
    > Thanks,
    > Lorenzo


    Yes.

    If you code your form so that the values are populated with the
    Request.Form variables, when it is first presented to users they will
    be empty. On submission, assuming validation failed, if you show the
    form again, the fields will be populated with the users submissions eg

    <form action="" method="post">
    <p>First Name: <input type="text" name="firstname"
    value="<%=Request.Form("firstname")%>"></p>
    <p>Surname: <input type="text" name="surname"
    value="<%=Request.Form("surname")%>"></p>

    etc

    /P.
    Paxton, Feb 24, 2006
    #3
  4. dNagel Guest

    Paxton wrote:
    > If you code your form so that the values are populated with the
    > Request.Form variables, when it is first presented to users they will
    > be empty. On submission, assuming validation failed, if you show the
    > form again, the fields will be populated with the users submissions eg


    Nice technique. I do most of my work in ColdFusion at this time and
    this would not work so well... CF would complain about the vars not
    being set initially, so there would be alof of CFParam tags...

    D.
    dNagel, Feb 24, 2006
    #4
  5. Paxton Guest

    dNagel wrote:
    > Paxton wrote:
    > > If you code your form so that the values are populated with the
    > > Request.Form variables, when it is first presented to users they will
    > > be empty. On submission, assuming validation failed, if you show the
    > > form again, the fields will be populated with the users submissions eg

    >
    > Nice technique. I do most of my work in ColdFusion at this time and
    > this would not work so well... CF would complain about the vars not
    > being set initially, so there would be alof of CFParam tags...
    >
    > D.


    I'm unfamiliar with CF. But in PHP you would have to check whether the
    variable has been set to achieve this kind of thing, otherwise you
    would get warnings:


    value="<?php if isset($_POST['firstname']) { echo $_POST['firstname'];}
    ?>"

    /P.
    Paxton, Feb 24, 2006
    #5
  6. Guest

    Paxton wrote:

    > If you code your form so that the values are populated with the
    > Request.Form variables, when it is first presented to users they will
    > be empty. On submission, assuming validation failed, if you show the
    > form again, the fields will be populated with the users submissions eg
    >
    > <form action="" method="post">
    > <p>First Name: <input type="text" name="firstname"
    > value="<%=Request.Form("firstname")%>"></p>
    > <p>Surname: <input type="text" name="surname"
    > value="<%=Request.Form("surname")%>"></p>


    Thanks Paxton, this is great stuff. First time I come across it...
    don't think the docs on MSDN mention this.

    Thanks again,
    Lorenzo
    , Feb 24, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Adams
    Replies:
    1
    Views:
    387
    =?Utf-8?B?U2hhaWxlc2ggSmFubnU=?=
    Aug 26, 2004
  2. Adam Knight

    REPOST - Parent List Data Item!

    Adam Knight, Nov 21, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    361
    Adam Knight
    Nov 21, 2005
  3. John
    Replies:
    1
    Views:
    2,476
    Ken Cox
    Dec 1, 2005
  4. lecnac
    Replies:
    1
    Views:
    3,777
    Jeff Dillon
    Apr 24, 2006
  5. Rajshekhar
    Replies:
    5
    Views:
    2,141
    Jonathan Bartlett
    Mar 29, 2005
Loading...

Share This Page