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

S

sujith.bolar

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
 
I

Ivan Marsh

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.
 
N

nutso fasst

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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top