By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,173 Members | 1,079 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,173 IT Pros & Developers. It's quick & easy.

rePOST form data without using GET

P: n/a
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 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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.
Feb 24 '06 #2

P: n/a

lb********@gmail.com 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.

Feb 24 '06 #3

P: n/a

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.
Feb 24 '06 #4

P: n/a

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.

Feb 24 '06 #5

P: n/a

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 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.