Redirect to 'another' previous page

P

Penny

Hi all,

I've built an online shopping cart using ASP Classic. The shop cart page
(with table showing customers selected items and costs) has only 3
buttons/links.

1: Back to Shop: Uses 'javascript:history.go(-1)' to go to previous page.

2: Remove Item(one next to each item in cart): Clears the selected item from
the session variable array redisplays the page.

3: Checkout: Proceeds nicely to the pages that collect the customers
details.

My Problem:

If the user clicks the 'Remove Item' link/button, the page efficiently
redisplays with the selected item removed from the list. However, if the
user then clicks either the 'Back to Shop' button or the browser Back button
(intending to continue shopping), the cart page redisplays showing the
removed item back in the list as it was before they removed it.

Although the session variable array remains correctly unaltered it is very
confusing to the user and will probably cause them to feel that their
shopping list has been 'messed up' and is now invalid.

I understand that the browser is just 'doing what it is told' but need to
find a way to avoid this confusing behaviour.

Any ideas,

Regards

Penny.
 
P

Penny

Hi askMe,

I get your point but seeing as the referring page is a dynamically created
search results page it is not feasible.

Penny.
 
S

Sandfordc

Hi Penny,

I may not understand your problem fully but here goes my idea.

When the user remove an item from the cart have the browser set a
cookie to reflect that then when the press 'Back to Shop' check for
that cookie if it is there then go back 1 additional time per removal.

function shop(){
ck=document.cookie
if(ck != null){
//get the value of the variable stored in the cookie
eval("history.go(-"+bk+")")
//bk is equal to the value of the variable in the cookie
}
else{
history.back()
}
}

Hope this helps.

Best Regards,
Sandfordc
http://www.javascript-central.tk
 
A

askMe

We are thinking very similarly. The only change I would suggest is to
make the page *always* look for the new variable instead of just when
the back button is pressed. Like, for example, whenever the page is
loaded, always ask for the cookie's value. From the description of the
problem, the cookie is holding the current value. The page in history
does not because it is not forced to be current.
 
A

askMe

If the page is dynamically created with, say, a database, then you
should have your delete procedure -also- write to the database. When
that happens, even when the user presses the back button, the database
resultset will end up refreshing the page content automatically because
a new call to the database occurs. If the cookie is simply stuck,
sometimes refreshing the page with javascript works, but it is not
reliable.

Hope this makes sense...

http://www.askblax.com
 
P

Penny

Thanks askMe and Sandfordc,

You both clearly understand my scenario. I'll look into implementing what
you've suggested and if not think about hold the sending pages full url and
parameters in a session variable and then retrieve that at the click of the
'back to shop' button.

Do you know of any places online I might find really comprehensive shopping
cart code ideas (asp). Free of course!!

Regards

Penny.
 

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,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top