473,385 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to update the current web page? (delete current web page + rewrite the page)

Hi,

Is there a way to update the same web page instead of getting a new
page each time we click the submit button? The simplest thing to do is
to delete the current page (or go back to the previous page) and then
redraw the page. There are a few possible solutions:

1. Use the same URL again. But a new page will still be created.

2. Use the "onsubmit" option:

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

3. Leave the page alone and use a customized javascript to update the
input fields of the current page:

<script language="javascript" >
function UPDATE(obj) {
frm1.txt1.value = Date().toLocaleString();
}
....
<form name="frm1">
<input name="foo" ONCLICK="UPDATE(this)" type="button">

4. Someone mentioned that one can post the form to itself. But he/she
did not explained the details.

By using javascript this way, the program still works as usual even if
javascript is turned off. Has anyone done this before?

Oct 12 '06 #1
3 5267
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?
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.

[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.
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?
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.

[snip]

Mike
Oct 12 '06 #2
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
Oct 12 '06 #3
kas...@yahoo.com wrote:
Michael Winter wrote:
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.
Actually you are right, the alternative 3 won't work if the
javascript is disabled.

Oct 12 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: red85 | last post by:
hello i have mysql 4.1 with win2000 SP3, i know that it is only an alpha and i don't know if someone else has already posted this problem: when i execute this sql UPDATE tableX SET...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
2
by: Christos Kalantzis | last post by:
Hello Gentlemen, I have a table which is the highest level table in my DB design...ie...all tables have foreign keys that if the chain is followed, lead to this table. This table had quite a...
4
by: Oscar Thornell | last post by:
Hi, I have a relativley large/complex typed dataset that contains 7-8 tables and some supporting relational tables (lookups) for many-to-many relations. A good exampel would be a dataset that...
3
by: Kevin Pedersen | last post by:
Hello, I am using an editable datagrid. After I save the changes the datagrid shows the old values. I've read the posts about the Page_Load and not binding the datagrid each time. The SQL that...
3
by: J055 | last post by:
Hi I have a PlaceHolder control inside a FormView EditItemTemplate: <asp:PlaceHolder ID="phResponseText" runat="server"> <tr> <td> <asp:Label ID="lblResponseText"...
0
by: aris1234 | last post by:
hello.. How to upload image file in page update ..?? i have logic like this : if user upload new image then old image must delete and update DB used new name if user not upload new image then...
2
by: RB | last post by:
Hi there, I'm having a problem with an ASP.NET/VB.NET Control I am writing. The control is a simple gallery control, which shows a set of thumbnails (using a DataList), and a main image of the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.