rePOST form data without using GET

L

lbolognini

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
 
D

dNagel

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.
 
P

Paxton

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.
 
D

dNagel

Paxton said:
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.
 
P

Paxton

dNagel said:
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.
 
L

lbolognini

Paxton said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top