in reply to How to re-capture/recall form field values AFTER pressing the 'BACK' button?

Thanks for your replies.

I prefer not to use the 'BACK' button and the scripts I write typically perform the validation within the script by using the script's URL in 'form action'. I'm using a pre-existing application and I'd like to revise it as little as possible.

What I'd like is for something like that used here on the Perlmonks site. For example, if you forget to fill in the title when creating a new node, the content in the text box is preserved when the 'BACK' button is clicked. How is this done?

Thanks.

  • Comment on Re: How to re-capture/recall form field values AFTER pressing the 'BACK' button?

Replies are listed 'Best First'.
Re^2: How to re-capture/recall form field values AFTER pressing the 'BACK' button?
by chromatic (Archbishop) on Jul 12, 2006 at 23:46 UTC

    The browser does that.

      To be more specific -- it's a function of the browser, and each browser can handle it as they wish. Some older browsers will re-populate everything (including passwords), others will populate all but passwords, some will save no state at all.

      So -- you can't depend on anything. You're better off doing off as others have suggested, and regenerating the form with the info populated as you wish (censoring passwords, etc, as required). This also gives you an opportunity to mark any problem fields that need correction (which is the normal reason for needing to show the populated form with the previous values)

      Oh -- and because this is undefined behaviour for the browser -- there are a few browsers that won't cache a POST, so won't reshow you the form, and thus you can't use the back button if the form was generated from a POST request.

      ...without being instructed to do so by PerlMonks.