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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to use "session" with a back button

Status
Not open for further replies.

dupuis2387

Programmer
Sep 25, 2006
9
US
A n00b question, from a n00b:

How can I create a button that replaces the standard
"back" button on every webnavigator, that when clicked on the current page, will take the user to the prev page
and keep all the choices that he made, before moving
to the page he is in , now?

I take it session("myvar")=page1.htm put into page1
and session("myvar") put into page2 won't do it, correct?



 
just store all the choices in session variables instead of tweaking the back button...

-DNG
 
Now, being a n00b as I am, may I ask for a link or something that can define how to do that?

remember folks, i did say n00b, so sorry for being so dee-tee-dee on all this.
 
On the page that receives the form contents, store all of the form variables to the session, with something like:

Code:
Dim formItem
For Each formItem In Request.Form()
  Session("form_" & formItem) = Request.Form(formItem)
Next

(I add "form_" to the start of the session variable name to facilitate easier removal of them later).

Then on the page with the form, simply write out the value of each input with the appropriate session variable e.g.

Code:
<input type="text" name="var1" value="<%=Session("form_var1")%>">
<input type="text" name="var2" value="<%=Session("form_var2")%>">

When you are satisfied that the form has been submitted properly, remove the session variables from memory e.g.

Code:
Dim sItem
For Each sItem In Session.Contents()
  If Left(sItem,5) = "form_" Then
    Session.Contents.Remove(sItem)
  End If
Next



Nick (Webmaster)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top