-Log in
-Register (free)


-RSS Feeds
-New MyDesk Module
-Update to Profile

Alternate color for RS looping with For Next
Northwind / ASP - Nested select
ASP SQL Injection




 Forums / Back to page 1 /

How to retain information..help pls.
new_learner | Posted 4:44am 12. February 2009 Server Time |

hi guys,
need a some help here..
This is what i am doing and what i need..

I submit the form from the first.asp and the information is on the second.asp in the formatted manner. I have two buttons on second.asp, 'Go back To Edit' and 'Send Email'. When i click on 'Go back to Edit' button(this would be redirected to first.asp) i loose all the information i had entered earlier, and i have to reenter all of it again..which is not goood. Can someone help with on how to retain the info when i click the button. If i use the 'Back' button of the Internet explorer, the information is there. But i would like to use 'Go back To Edit' button to retain the information. Any help would be highly apppreciated...thank you.
katy8439 | Posted 5:40am 12. February 2009 Server Time |

You need to use a Session variable to store your data. This can then be called on any page on your site. For Example:

First.asp Page
-----------------

<input type="text" name="FirstName" value="<%=Session("FirstName")%>" />

If the Session Variable "FirstName" has been set the value will be displayed, if not the user will see a blank input field.

To set the session variable, you need to grab the form data on the second page:

second.asp
-----------

Session("FirstName") = Request.Form("FirstName")

so when the user goes back to first.asp, they'll now see the fields populated with the data they previously entered

Hope that helps!

Katy

new_learner | Posted 3:05am 13. February 2009 Server Time |

Thank you katy, it worked for few fields however it does not work with 'textarea' input box...any idea?

other thing i noticed is that even if i refresh the first page it does not clear the fields in that. Just incase i would like to reenter the information from beginning...

thank you once again.
katy8439 | Posted 8:50am 17. February 2009 Server Time |

The easiest thing to do to "start from the beginning" is to put a reset button on the form which should clear all the values out:

<input type="reset" value="Click here to clear form" />

To get the value into the textarea you need to put it in between the textarea tags. For example, if you stored your text area form results in a session called "Comments" you'd do the following:

<textarea name="Comments" rows="5" cols="10"><%=Session("Comments")%></textarea>

new_learner | Posted 3:47am 18. February 2009 Server Time |

Thanks a lot, it worked..you are great :)

One more help...how should i assign for list boxes and check boxes???
katy8439 | Posted 6:14am 18. February 2009 Server Time |

By List box I assume you mean a drop down list? One way of doing that would be:

<select name="mylist>
<option value="1" <%IF Session("MyList")=1 THEN%> selected <%END IF%>>1</option>
<option value="2" <%IF Session("MyList")=2 THEN%> selected <%END IF%>>1</option>
</select>

Checkboxes would work in a similar way, you need to check the session value against the value of the box and mark it as checked if they match
new_learner | Posted 11:08pm 19. February 2009 Server Time |

Thanks a lot, it worked again. I would be back with some more queries soon. i am loving it :)

Thank You once again, Katy :) Have a Great Day!!!!
1
Show all replies to 'How to retain information..help pls.'
This post have been closed for new replies



| Info |
© Copyright 1997-2013 Alexander Haneng