Jump to content

Dhtml Refresh Issue


GregL83
 Share

Recommended Posts

Hey all,I have been working with a javascript popup calendar for awhile now and have run into some funny behavior. The calendar loads values into an input field; however, when the browser is refreshed the input field doesn't clear... I have been developing for awhile and I have never encountered this issue.The calendar I am using can be found at:http://www.mattkruse.com/javascript/calendarpopup/index.htmlI have tested this in FF3 and IE7 with the same results.Why won't the form values clear? How do I have them clear while being unobtrusive?Please help. this problem has plagued me for awhile now...

Link to comment
Share on other sites

In my experience, that's normal for a page refresh.awitt's suggestion will work, but you'll need to do it one of two ways. (1) put the statement in a window.onload handler, or (2) put it in a mini-script in the body, somewhere after the input element itself. getElementById() fails if the element hasn't loaded yet.

Link to comment
Share on other sites

Hmm. ok.What I am wondering is why the form elements don't clear? If I do: document.getElementById('input').value = 'test'; and hit refresh the value clears. I am trying to figure out why, in this script, do element values remain after refreshing the page?What is storing these element values? How does a stateless web page carry over values?Also, if I wait a certain amount of time and refresh (1-3 min) the values clear.....Thanks for the responses.

Link to comment
Share on other sites

A web page isn't necessarily stateless. It could be saving and reading the value using a cookie, which will get sent back on refresh.
the issue here is that the actual browser is holding the values. browsers consider this a feature - for example, you're putting in an order for a product, and after you enter your billing address, you realize it was wrong. so you hit back, and boom!, there's your info still on the page. most browsers have a timeout set so that the info they're holding on to will only be accessible for a limited period of time (say, one to three mins). that's why D.Dad was saying to put the manual field reset in the window.onload function, cus if the values are saved, when the page and it's elements are loaded, you can just set them to nothin
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...