Redirect to 'another' previous page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Penny

    #1

    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:his tory.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.


  • askMe

    #2
    Re: Redirect to 'another' previous page


    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.




    Penny wrote:[color=blue]
    > 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:his tory.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.[/color]

    Comment

    • Penny

      #3
      Re: Redirect to 'another' previous page

      Hi askMe,

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

      Penny.


      Comment

      • Sandfordc

        #4
        Re: Redirect to 'another' previous page

        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.coo kie
        if(ck != null){
        //get the value of the variable stored in the cookie
        eval("history.g o(-"+bk+")")
        //bk is equal to the value of the variable in the cookie
        }
        else{
        history.back()
        }
        }

        Hope this helps.

        Best Regards,
        Sandfordc


        Comment

        • askMe

          #5
          Re: Redirect to 'another' previous page

          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:[color=blue]
          > 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.coo kie
          > if(ck != null){
          > //get the value of the variable stored in the cookie
          > eval("history.g o(-"+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[/color]

          Comment

          • askMe

            #6
            Re: Redirect to 'another' previous page

            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...



            Comment

            • Penny

              #7
              Re: Redirect to 'another' previous page

              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.


              Comment

              Working...