We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


How to refresh a page and not clear form contents

lshane asked
Medium Priority
Last Modified: 2008-01-09
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.
Watch Question

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...


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?
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).

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


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.


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.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.