This is an html issue. Unfortunately, what you want to do is contrary to standard browser/form/html behavior, so any solution will be some sort of hack. A reload button or link is the cleanest, easiest solution, but doesn't allow the user to use the reload button on his/her browser. Allowing the form to be resubmitted (and ignoring it) is a bad idea - it will be confusing to your users, whose browsers will ask (every time) if they really want to resubmit the information (plus, it's a lot of work). Redirecting after the form submission is also bad because it hoses the back button (although you might be able to change the behavior of the back button with javascript - you could probably get some inspiration from porn popups on how to do that). Plently of websites hose the back button in this way, but that doesn't make it less of a sin.

There is a horrible hack to do exactly what you want, but it involves frames (iframes might work) and javascript. Basically, you have to subvert the standard form submission process - instead of having your form's submit button actually submit the form, have it set off some javascript (using onClick) in another frame (iframe?) - we'll call that frameB - that submits a form (from frameB) with the information from the original frame (frameA - the one with the form the user filled out). When frameB comes back from the server, it reloads frameA using javascript (you may have to shift focus back to the original window, again with javascript). The back button works - the reload button works - and there is no annoying "are you sure you want to resubmit the form" warning message. Since you are coding an application, frames are not a Bad Thing.

If you don't have frames in the application already, I'd just do the reload button/link (although you could see if the javascript/frames thing works with iframes - I can't see why it wouldn't)...

In reply to Re: CGI Reload Forms by bean
in thread CGI Reload Forms by lantern

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.