473,386 Members | 1,830 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,386 software developers and data experts.

Redirect to 'another' previous page

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.
Jul 23 '05 #1
6 2217

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.


Jul 23 '05 #2
Hi askMe,

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

Penny.
Jul 23 '05 #3
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

Jul 23 '05 #4
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


Jul 23 '05 #5
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

Jul 23 '05 #6
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.
Jul 23 '05 #7

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

Similar topics

1
by: Dwayne | last post by:
I use Respose.Redirect quite a bit but on one of my pages it has an odd behavior. Any time I use it on this page it will come up in a new Window. I didn't even think this was an option and can't...
0
by: LjP | last post by:
I am trying some examples from Developing web app book. This one is suppose to redirect / transfer to another page: WebForm1.aspx has one button and one text box: Private Sub Button1_Click(ByVal...
4
by: Matthew Wieder | last post by:
On my Page_Load event, i need to do some validation and then either let them proceed, or display a error message and boot them back to the previous page. Here is the code: ...
3
by: Justin | last post by:
Hi, Im confused here over the usage of Response.Redirect and Server.Transfer. I used frameset for my work, what are the proper usages of the two methods that seems working similar.. The...
2
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control...
7
by: Markus McGee | last post by:
Hi all, I have a quick question...I believe. On my web page, call it page A, I have a drop downlist with runat server enabled. When the drop downlist change event occurs it repopulates a...
4
by: Matt MacDonald | last post by:
Hi everyone, I'm seeing this problem more and more often. Not sure if it's me or IIS or both. Here's the general scenario: I have an ASP.net app that is running and I try to navigate to...
5
by: Doug | last post by:
In the code below, I am trying to go from one asp page to another: For Each tripToAccept As String In tripsToAccept.Split("/"c) dataManager.UpdateTripDetail("Accept", CInt(tripToAccept),...
5
by: Lupus | last post by:
Hi there! I have some strange behavior in a ASP VB.NET application. I've used response.redirect many times in different pages, and it works like a charm. However in a new page I'm making, the...
4
by: valhalen | last post by:
Hi, I am trying to redirect the user to another page (other than the previous one in the browser's history) when the browser's (IE's) BACK button is clicked. I found this snippet, but am finding...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.