How to refresh a page and not clear form contents

Hi. I am using ASP VBScript (not .NET).

I have created a form on a page.  When data is entered, I would like for it to remain after refreshing the page.  I will clear it with the "Clear" button, but I don't want it to clear until then.

I'm not sure if this has something to do with "Session Variables", or not.

Could someone, please, assist me with this?

Thanks so much.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi lshane!
add script to your file

window.onload = function () // when the window is reloaded, check if a scroll value has been saved
Depending on what you mean by "refresh" (I'm assuming you don't mean "submit", because then all you'd have to do is prent out the received values) there is one solution that I can see, with two methods: use javascript to save the values as they are typed.

The time increment is up to you but I'd suggest saving values after 5 seconds of keyboard inactivity.  Now as to where you save the values, you could save them either to a cookie (if they are small values, remembering a cookie has limited size and not everyone has them turned on) or to a server (using a sessionid as the person's identity).

This idea is taken from one of the fundamentals of the Javascript tecjnology named Ajax, so either look around EE for more help on that or browse the hundres of tutorials on the web.  Basically you're saving what people type as they type, so when the page is refreshed you can pull back the information as it was stored only 5 (or whatever) seconds ago.

Of course, if the user doesn't have Javascript turned on this technique won't work and I can't think of a non-scripted solution...
lshaneAuthor Commented:
Good points.  I am actually referring to when someone presses the "refresh" button on the browser.  That always clears the form.  Perhaps it should.  I was mainly wanting to know if there was a way to keep it from clearing when the "refresh" button is pressed, and to only clear when a user presses the "Clear" button on the form.

Is that possible, or even useful?
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

As above, I can't think of any other way to keep the state in an inherently stateless system.  You can't stop the refresh working, it is meant to clear form values as you suggest... all you can do is hopefully store the data away somewhere (cookie or database) every so often (like an autosave function, essentially) and pull it back from that store when the page is refreshed (serverside or ajax-ified, that's your call as the developer -- I'd stick with serverside myself, it's far more simple).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lshaneAuthor Commented:
Great. I suppose that is what I was needing to know... that the "Refresh" button is meant to operate that way.  It seems that what I was trying to do may not even be useful unless the user has a LOGIN.

Thanks so much.
No problems, thank you :)

As an aside: to use the options I've listed above, the user wouldn't have to be logged in as they would be given a session ID when they open their first page -- if you keep that session ID with them all long the way (either as a querystring value, and/or hidden inside forms) then it doesn't matter if they are logged in or not, you can still track them and so still save the data as attached to that sessionID.  Just a thought.

lshaneAuthor Commented:
Great.  Thanks for the addendum.  I still have some things to learn with ASP, clearly.  Just trying to grasp the theory at the same time.

Thanks so much.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.