Form input fields reset problem

Discussion in 'Javascript' started by apstein, Dec 1, 2007.

  1. apstein

    apstein Guest


    I have an HTML form (generated by php) which I am rendering in
    Internet Explorer 6.

    My original problem was that if the user submitted the form, and then
    used the back button to return to the form (desirable ability), then
    all the fields in the form would reset to their default values,
    forcing the user to re-enter them to submit the form similarly as

    I fixed most of those resets by doing (IE 6): Tools -> Internet
    Options (General tab) -> Settings -> Check for newer versions of
    stored pages -> Never -> OK -> Delete Files -> Delete all offline
    content (checked) -> OK -> OK.

    This prevented selects and plain text fields from resetting. However,
    some text fields with defaults set using JavaScript date libraries
    continue to reset to their defaults.

    Notes: this does not occur in Firefox. I am using frames populated
    dynamically (javascript). Another highly similar page (static html
    only, no php) does not exhibit this in the same browser.

    Any help would be appreciated.

    apstein, Dec 1, 2007
    1. Advertisements

  2. apstein

    Doug Gunnoe Guest

    And you would like for all the fields to keep the values the user

    This is easy to do in PHP. Try a search on "sticky forms PHP".

    Alternatively, if you could validate the fields using javascript, you
    would not need a sticky form.
    Doug Gunnoe, Dec 1, 2007
    1. Advertisements

  3. apstein

    andrew Guest

    Hi Doug,

    Thanks much for your response. I had been checking into the sticky
    forms approach, but I mainly found that to be used for form
    validation, when submitting to PHP_SELF. In my case, the form had
    already been submitted correctly, and I was just trying to go back to
    it for modification and resubmission. Thus, no reload from the server
    should have occurred (?? see below).

    I had been executing my default date setting JS from a BODY onLoad
    event. What I could not understand was that the browser "Back" button
    event was being interpretted as an onLoad event. Strangely, too, it
    was not actually reloading the page, because all of the other defaults
    (selects and inputs) were retained. It was just that the browser was
    interpretting it as an onLoad and executing the JS.

    Eventually, I opted to store a "pre_submitted" boolean (initially set
    from the form submission function) in the PARENT document, then use
    that as a pre-condition for the onLoad event to execute the default
    date JS. A long road but it seems to be working!

    Thanks again!
    andrew, Dec 3, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.