• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how do I get around "onLoad" in my app

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.javascriptkit.com/javatutors/cookie2.shtml
 
reply
    Bookmark Topic Watch Topic
  • New Topic