[ic] Simple if-then to compare checkout page variable to updated variable after page update? What am I doing wrong?

Tim Murphy goombah@netcom.ca
Sun, 25 Feb 2001 11:37:22 -0500


Apologies for the previous HTML...fixed the formatiing...

Hello all,

    After staring at the screen trying to figure out my undoubtedly dumb
mistake, I'm cross-eyed and need another head or three to look at this and
point out my thickiness. I am attempting to set a scratch variable to the
value of the form variable "country" on the checkout page. Then after
someone has updated the shipping info and the page hs been resubmitted I
want to compare the scratch variable containing the pre-update country value
to the just-submitted new country value, and then of course set the scratch
variable to this most recent value for further comparisons. I thought I
understood the sequence of processing an Interchange page but I must be
missing something. It seems to me that the comparison between the old
country value (in a scratch variable) and the newly updated form country
value should proceed before the scratch variable is updated with the new
country value, but my comparison ALWAYS returns true, that they are equal.
This is a code snippet:


FIRST VISIT TO PAGE?

[if !scratch visitcount]
   [perl]
      $Values->{country} = CA0;
      $Values->{state} = QC;
      $Values->{mv_shipmode} = "can_a";
      $Scratch->{visitcount} = 1;
      $Scratch->{previouscountry} = $Values->{country};
      return "FIRST VISIT.\n";
   [/perl]
[else]

PROBLEM HERE:

   [perl]
      $prevcountry = $Scratch->{previouscountry};
      $country = $Values->{country};
    ------->  if("$prevcountry" eq "$country") {  <------- ALWAYS TRUE, WHEN
DOES FORM VARIABLE "COUNTRY" GET NEW VALUE?
         $info = "COUNTRY NOT CHANGED, previous country is " .
$Scratch->{previouscountry} . " and current country is
$Values->{country}.\n";
         $info;
      }

      else {

         if("$Values->{country}" eq "CA0") {
            $Values->{state} = "QC";
            $Values->{zip} = "";
            $Values->{mv_shipmode} = "can_a";
            $info = "COUNTRY SET TO CANADA, previous country is " .
$Scratch->{previouscountry} . " and current country is
$Values->{country}.\n";
            $info;
            $Scratch->{previouscountry} = $Values->{country};
         }
         elsif("$Values->{country}" eq "US0") {
            $Values->{mv_shipmode} = "can_us_a";
            $Values->{salestax} = "";
            $Values->{state} = "NJ0";
            $Values->{zip} = "";
            $info = "COUNTRY SET TO US, previous country is " .
$Scratch->{previouscountry} . " and current country is
$Values->{country}.\n";
            $info;
            $Scratch->{previouscountry} = $Values->{country};
         }
         else {
            $Values->{mv_shipmode} = "can_intl_a";
            $Values->{salestax} = "";
            $Values->{state} = "";
            $Values->{zip} = "";
            $info = "COUNTRY SET TO INT, previous country is " .
$Scratch->{previouscountry} . " and current country is
$Values->{country}.\n";
            $info;
            $Scratch->{previouscountry} = $Values->{country};
         }

      }
   [/perl]
[/else]
[/if]


I just can't see why something that seems so simple isn't working, which
means it's time for wiser heads to prevail. Could someone take a moment to
correct either my understanding of the whole page processing operations or
(I hope) point out a really dumb error?


Thank you,

Tim