Michael Winter wrote:
la*****@yahoo.com wrote:
Is there a way to update the same web page instead of getting a new
page each time we click the submit button?
Would you care to clarify what you mean? I presume that you want the
form to remain. Do you want the values to be cleared, too?
I have many "Load' submit buttons on the page, one for each file to
be uploaded. So When user clicks one of these 'Load' button, I wish I
can upload the chosen file and refresh the screen with the same
form/page. This way if they upload 10 files and click "Back" button of
the browser, they will go back to the previous page, not the 9 pages
that the browser normally created during the process. (I also have a
"Load All" button to load all files all in once.)
The simplest thing to do is to delete the current page (or go back to
the previous page) and then redraw the page.
The simplest thing to do is re-serve the document. You haven't suggested
why that's not possible.
How to re-serve the document without getting a new page? I thought
the browser always create a new page for the history record that I am
trying to avoid.
[snip]
<form ACTION="testnet.pl" method="post"
ONSUBMIT="javascript:history.go(-1); return false;">
.... <input..>
but the browser goes back to the previous page yet does not
continue to the ACTION part to draw the same page with new data.
Of course, because you're cancelling the submission.
It is merely there to indicate that the browser can only do either
"onclick=history.go(-1)" or "action" in this case. If it executes the
"onclick=history.go(-1)" to go back to the previous page, it is already
on different page/form thus it won't be able to submit anything. This
is why as far as I know no one has used the "history.go(-1)" and submit
(action) as well. The browser just go back to the previous page and
never submit any data to the server so that it can draw a new page.
3. Leave the page alone and use a customized javascript to update the
input fields of the current page:
[snip]
And when scripting is disabled?
Those user who has javascript disabled will see the whole history
stack as usual. Those has javascript enabled will see just one page
that gets updated.
4. Someone mentioned that one can post the form to itself. But he/she
did not explained the details.
The same as option 1: submit the form to the same URL, and determine
server-side whether a request is a form submission, or not.
Whenever I submit a form to the same URL I get a new page unless
there is a way that the server can ask the browser (client) to go to
the previous page first.
I tried to do this by running the javascript
:history.go(-1) in the
body. This is the fifth and sixth alternative:
5. Execute javascript when the server sends the form:
<html><body>
<script language="JavaScript">
javascript
:history.go(-1); // ask the browser to go back
</script>
</body></html>
<html>body>
<form.... // then draw a new form
<input....>
</body></html>
When I ran it the browser refreshed the screen and went to the
current page again. So it didn't work. I also tried putting the
history.go(-1) inside the second <htmland got same result.
6. Ask the browser to delete the current page first before drawing new
page:
I couldn't find anything on the internet to suggest how to do this.
[snip]
Mike