Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

REFRESH problem.

Status
Not open for further replies.

A1Pat

IS-IT--Management
Jun 7, 2004
454
US
hello all,

I'm not sure this topic of my is related to this forum; I try anyway.

I have a shopping cart ASP page that when a user select BUY button which I included:
<form name="additem" action="cart.asp" method="post">
<input type="hidden" name="action" value="additem">
<input type="hidden" name="idProduct" value="1448">
<input type="hidden" name="quantity" value="1">
<input type="SUBMIT" name="submit" value="BUY NOW!">
</form>

the page will than redirect to cart.asp page and the order is display on a shopping cart. My problem is when I refresh the cart.asp page, the number of order is automatically adding 1 to the order itself, and the so on.

On cart.asp page, I see this code keep showing 1 when I refreshed:
Quantity = Request.Form("quantity")

How can I turn it off the automatically adding when the page is just refreshed by user.

thanks.
 
What I am betting is happening is that on your cart page you are re-adding the product at quantity of 1, thus getting 2, 3, 4, etc as you refresh.

One option would be to only allow the user to add an item to their cart once, and then any subsequent submissions for that item treat as a quantity adjustment.

Before your logic for adding an item to the cart, do a check in the cart to see if that item has already been added. if so, then simply change the quantity to the posted quantity, otherwise if add it to the cart. What this will do is not only allow any number of refreshes on the cart page without increasing the amount in the cart, but will also give you an easy capability to change the quantity of the items simply by posting the product and an updated quantity to your cart page.

-T

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top