Values entered in the Form disappears when using the history.go(-1) or history.back()

Discussion in 'Javascript' started by sujith.bolar@gmail.com, Oct 16, 2006.

  1. Guest

    Hello

    I am using a <form method="post"> to submit values to the processing
    agent. If the processing agent returns an error, I call the
    history.go(-1) or history.back() function to reload the page. The page
    does reload but all the values entered disappears.

    I am using Java Script and html.
    Code:
    ---------------------
    I am filling in the form in "name.html" file.

    </head>
    <body class="main" onload='startup()'>

    <center>
    <form method="post" name="example" id="example">
    <table>
    <tr>
    <td>Name:</td>
    <td>&nbsp</td>
    <td><input type="text" name="name" size="64"
    maxlength="64"></td>
    </tr>
    </table>
    </form>
    </center>
    </body>
    </html>


    When the processing agent return error, the page is redirected to
    "error.html " where the code looks like below:

    <script type="text/javascript">
    <!--

    function submit()
    {
    history.go(-1); // I tried history.back() too but no luck
    }

    -->
    </script>

    </head>
    <body class="main">
    <br>
    <br>
    <table>
    <tr>
    <td>
    <center>
    <table>
    <caption class="cap">Error</caption>
    <tr><td> WRONG NAME </td></tr>
    </table>
    </td>
    </tr>
    <tr>
    <td>
    <table>
    <tr>
    <td> &nbsp </td>
    <td width="100">
    <div id="okButton" class="tbutton"
    onmouseup='submit()' Ok </div>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </body>
    </html>


    In case an error is thrown, the name.html is loaded as expected but I
    lost the values entered in the form.
    What should I do to store the values ?

    Thanks
    I would appreciate any help/repsonse to my question.

    - Sujith
    , Oct 16, 2006
    #1
    1. Advertising

  2. Ivan Marsh Guest

    On Mon, 16 Oct 2006 14:13:41 -0700, sujith.bolar wrote:

    > I am using a <form method="post"> to submit values to the processing
    > agent. If the processing agent returns an error, I call the
    > history.go(-1) or history.back() function to reload the page. The page
    > does reload but all the values entered disappears.


    Of course they do... the page is being re-loaded and none of that data is
    part of the page.

    Your error processing page must pass and reassign the values to the input
    boxes.
    Ivan Marsh, Oct 16, 2006
    #2
    1. Advertising

  3. nutso fasst Guest

    <> wrote in message
    news:...
    > In case an error is thrown, the name.html is loaded as expected but I
    > lost the values entered in the form.
    > What should I do to store the values ?


    Form variables are lost when you redirect. If you must do this, put them in
    a cookie.

    nf
    nutso fasst, Oct 17, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TN Bella
    Replies:
    1
    Views:
    1,492
    TN Bella
    Jul 1, 2004
  2. vishal
    Replies:
    2
    Views:
    1,112
  3. Luke Matuszewski
    Replies:
    8
    Views:
    128
    Luke Matuszewski
    Apr 22, 2006
  4. Bruno

    Back (history.back()) after refresh

    Bruno, May 29, 2006, in forum: Javascript
    Replies:
    2
    Views:
    319
    Bruno Lopes
    May 30, 2006
  5. venkat reddy
    Replies:
    1
    Views:
    299
    Elegie
    Jul 8, 2011
Loading...

Share This Page