How to make the page self refresh once when the page is loaded

Hello, friends. I wonder how to make the page self refresh when it is loaded.

I have code like
<body onload=“self.location=self.location”>

Then it start to refresh on and on when the page is loaded.
How should I code so that it only refresh once when the page is loaded?

Thanks very much in advance!Regards!

<%@ Language=VBScript %>
<%
Option Explicit
Response.Expires = 0
Response.Buffer = True
Response.Clear
Response.AddHeader “Refresh”, “10”
%>

Set Expires to 1 if if you don’t want it to cache.

Change 10 to the number of seconds you want to happen before it refreshes.

Or do a simple
<%
Response.Redirect “mysite.com/mypage.asp
%>

hi, thanks for your code. But seems that isn’t exactly what I want. Actually, my situation is making a shopping cart. And when the user add one more product into the shopping cart, the total number within the shopping cart increase by one and shown on the corner of the page immediately when it is done. So I would like to know how does people usually achieve this effect? I define that total number number to be session(“number”). But it only refresh on the following page. So how could it be possible to make it shown on its own page immediately when new product is added.

Thanks !

add the refresh script to that processing script- as the script is processing add the refresh

so if you have

<%
processing crap here…
Response.Redirect “www.mysite.com/currentpage.asp
%>

as long as everything they are doing is still stored in session and db should be fine

thats what happens when you update quantities, or totals- it calculates the new data, stores it, then recalls the page based on session data and db data.

there is another possible method where you can re-store the variable by having the page post to itself, then have another button that submits it to the db for finalization

either way works.

play around with both methods, i’m giving you wireframe so you get to use ingenuity- i’ll be back this afternoon.

hi, thanks for you suggestion. Then how should I code so that when the user click the remove button to remove one item from the shopping cart and the session(“number”) will decrease by one immediately. Is it I should add action for refreshment on the button of removing and how?

and actually I am one the refresh page also the data to input into the database. If let it refresh, the original data will be updated with all 0 values. That is problem, isn’t it?

to the second post:
If you have all of the data values such as quantity and price in the database; then update the total price because you changed something; technically it would resubmit the same values.

All of your price, tax, and totals…etc… should be calculated using the database fields. Not from just the page itself.

Also you could have a script that looks for changes upon submit…if it doesn’t detect any it just leaves everything alone, if it does detect a change it uses the “update” command for recordsets to update that value.

So basically all of your entered items(quantity, price) should be in a database matched to a session ID…

Whenever it loads the page to view the “invoice”…ya know like most online shopping carts display how much of this and that…

those values once entered and submitted, should be stored in a db… then if the customer wants to go back and change anything, when it views the values- those values in the fields should be pulled from the database…then when someone changes the numbers…use the update command for recordsets and it will update all the records…


When the form is loaded up the first time-there will be no objects in the recordset, so you have to have error handling to display 0 in the fields upon load.

Now the customer starts ordering stuff:

lets say that you have “item 1” and “item 2”

customer buys 2 of item 1 and 4 of item 2:

item 1 costs $1.00

item 2 costs $5.00

So the forms would look like:
Description Price * Quantity Total
Item 1 $1.00 * 1 $1.00

Item 2 $5.00 * 4 $20.00

Ok this is what they entered: These values should then be stored in the database.

But wait the customer meant to buy 6 of Item 1!!!

So after they submitted the information to the database, the page refreshed itself…this time the form fields could pull data from the recordset. The data they entered into the database is then displayed in the form fields…which are editable!!!

So they just change the quantity of item 1 to 6 and then click submit!!!

Using the update for recordsets command; it merely updates the data in the DB and then refreshes the page showing the new data…

If the customer is done shopping, they click “done” and then get forwarded to the final pages…

objRecordset.Update

would be the command

objRecordset being the name assigned to your record functions
here is some kind of sample for you
http://www.asp101.com/samples/viewasp.asp?file=db_update.asp
^review that link for how they updated the information…

mainly just the record calling and updating…
I’ve had to do the same thing with my member databases. Not a shopping cart, but the ideas are the exact same.

Hi, thanks so much about your explanation and your link. I am tring that one my code. I will consult you if there is still some problem. And by the way, could I ask which kind of database you are using? Because there is always the question like which database server should the designer use. Currently, I am using Microsoft sql server 2000. And I know there are My SQL and also Microsoft sql server 7, and maybe XML server. Do u have some experience of comparation among them?

Anyways, do thanks alot for your help and clear explanation. Regards!

Hey, no problem at all.

Microsoft’s SQL server is awesome. We have the enterprise up and running at work.

Personally my php sites use MySQL and my ASP sites Microsoft Jet and Access. I prefer Access servers.

They just seem to run quicker, and easier; and for me the coding is more efficient.

I could default to the adage that “whatever you know and works for you” should be what you use.

I am bias though to the Access servers. I just enjoy how they run and I never ever seem to have any problem with them.

The server at work though is a dream machine; and the enterprise package gives a GUI for maintaining the actual databases.

So, it’s about 50% Microsoft Access. 25% Microsoft SQL. 25% MySql.

Hope that helps; these questions are always hard for me to answer.

Please keep updating the status of this project. I’ll be interested to see the final product.

Also if you encounter anything else, let me know.