File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes how do I get around Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how do I get around "onLoad" in my app" Watch "how do I get around "onLoad" in my app" New topic
Author

how do I get around "onLoad" in my app

kay lin
Ranch Hand

Joined: May 20, 2004
Posts: 132
Hi All:
I have an app, that would display a date field. if a page is first load up, it would display today's date as default, this is achieved by using the onLoad tag and set it like the following:




The user can choose to enter any date they wish as well, but the problem comes when the user goes to the next page, and hit the "back" button on their browser, now they are suppose to see whatever they have entered in the date field, but because of this


thing, every time, the user hit the "back" button, the default date will be displayed, which is not Desirable.

So my question is , how can i get the page to display the default DATE only ONCE when it first loads up, and when a user hits the "back" button on the browser, he will see whatever he has entered.


if anyone could possibly help me with it, i'd TRULY appreciate it.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Check to see if the date field contains any information before filling it in

if(document.FormName.ElementName.value.length==0)document.FormName.ElementName.value = new Date();

or
You can use session cookies...

Eric
kay lin
Ranch Hand

Joined: May 20, 2004
Posts: 132
Originally posted by Eric Pascarello:
Check to see if the date field contains any information before filling it in

if(document.FormName.ElementName.value.length==0)document.FormName.ElementName.value = new Date();

or
You can use session cookies...

Eric


How do I use a session cookies to do this? could you give me a hint/example? many thanks
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
http://www.javascriptkit.com/javatutors/cookie2.shtml
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how do I get around "onLoad" in my app