Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing form contents to a 3rd page

Status
Not open for further replies.

Microbe

Programmer
Oct 16, 2000
607
AU
Hey everyone,

The scenario is a page that gets user registration details. I do a bunch of Javascript validation, but the only way I can see to validate that the postal code matches the suburb is after the submit. No big deal, I can even test for a non-existant suburb (spelling mistake?).

So if I find that the suburb does not match the postal code I want to push them back to the form with a message indicating the problem.

My problem is how to retain the details they have already entered (e.g. name, address, phone etc) without creating a super long querystring. Given that the form object is already populated I figure there must be a way of passing it and its contents back to the page without submitting it.

Any thoughts?

Thanks in advance

Steve


Steve Davis
hey.you@hahaha.com.au
 
I've never tried this, but it's worth the effort. Try the Server.Transfer method. I believe it looks like this.
Code:
Server.Transfer("backtopage.asp")
If I remember what I read about this command, it retains all of the collections including form and querystring. Then you could write something like this in your original page.
Code:
<input type=&quot;text&quot; name=&quot;firstname&quot; value=&quot;<%=Request.Form(&quot;firstname&quot;)%>&quot;>
If there is no Request.Form(&quot;firstname&quot;) then the text field will just be blank. If there is a Request.Form(&quot;firstname&quot;) value, it will be put in the field. My understanding is that Server.Transfer is only supported on newer releases of IIS.

ToddWW
 
One other thought that might help if Server.Transfer is not successful. Try populating a Session Dictionary Object or Array with the form collection then returning to the page and accessing that collection. Then back on the original page, use Session(&quot;dictobjname&quot;).Exists(keyvalue) to search the object for value. Or when redirecting to the original page you could put a key/value pair in your querystring telling ASP that this is a return and that the Session(&quot;dictobjname&quot;) object exists. Then loop through that object and place the values back in your text fields. Since you created the dictionary object with a set number key/value pairs, you should have no problem accessing those without needing to issues the Exists method.

ToddWW
 
have you tried using history.back? (I don't know if it is right) That JS that is like the Browser's Back button. I think it might work..
 
THanks for the suggestions...

I am not sure the problem, but I just can't get session.transfer to work...never have. I reckon it would be the solution as it is supposed to transfer all the variables to the new page, but I get an error when I try to use it. I have even tried troubleshooting using a really simple page, but no go. Anyone cracked this?

history.back() is a good idea, but I want to redraw the page with something like &quot;wrong postal code&quot; next to the text field to highlight where the problem is.

A session array may be the way to go. Didn't think of that. Better that a mile-long URL.

Thanks for the suggestions. I love this forum.

Steve Davis
hey.you@hahaha.com.au
 
I bring up a new .asp that has the message (&quot;OOPS!) and an &quot;OK&quot; button.
In the button_click, use history.back(2) which brings back the first form.
 
Thanks for the idea Tim.

It would certainly work, but it is not particularly elegant. I am working on session arrays at the moment as a solution.
Steve Davis
hey.you@hahaha.com.au
 
Hi,

You might also want to consider just using a <DIV> tag to create a layer and show the layer with your &quot;Wrong Postal Code&quot; note combined with the History.back...

Use [a] hidden variable(s) to indicate whether the page has been accessed, change the variable on the first go-around and then have the page look for the variable. If the variable has been changed then show the layer...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top