Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Redirect to 'another' previous page

Reply
Thread Tools

Redirect to 'another' previous page

 
 
Penny
Guest
Posts: n/a
 
      05-26-2005
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.


 
Reply With Quote
 
 
 
 
askMe
Guest
Posts: n/a
 
      05-26-2005

Can you modify the 'Back to Shop' button to point to the actual page
again instead going back? If so, use href= or location= to do the
trick.

http://www.askblax.com


Penny wrote:
> 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.


 
Reply With Quote
 
 
 
 
Penny
Guest
Posts: n/a
 
      05-26-2005
Hi askMe,

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

Penny.


 
Reply With Quote
 
Sandfordc
Guest
Posts: n/a
 
      05-27-2005
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

 
Reply With Quote
 
askMe
Guest
Posts: n/a
 
      05-27-2005
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.


Sandfordc wrote:
> 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


 
Reply With Quote
 
askMe
Guest
Posts: n/a
 
      05-27-2005
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

 
Reply With Quote
 
Penny
Guest
Posts: n/a
 
      05-27-2005
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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Response.redirect does not redirect from .aspx page =?Utf-8?B?VHJveQ==?= ASP .Net 3 10-15-2008 09:07 PM
How to I know the previous page is clicked to forward the current page? ABC ASP .Net 2 01-14-2006 09:30 PM
Issues with navigating to previous page and keeping custom page properties available Greg Krzeszkowski ASP .Net 3 03-03-2005 04:59 PM
Basic Q - Response.Redirect, all redirect to first Response.Redirect statement Sal ASP .Net Web Controls 1 05-15-2004 03:46 PM
CGI: redirect some value to the previous URL Wenjie Perl Misc 1 10-04-2003 10:41 PM



Advertisments