simple 4 variable calculator won't work

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adweaver
    New Member
    • Oct 2009
    • 20

    simple 4 variable calculator won't work

    I've been pulling my hair out on this one for a while. I even have a working version of the code and a side by side comparison has led me nowhere.

    If anyone can provide some insight on what I've done wrong here, I'd be greatly appreciative. I'm still fairly new to all this, so any suggestions on how I could have worked this out myself help as well.

    The basic premise of this is 4 possible outcomes. Standard Shipping or Expedited, and with our without delivery confirmation (for both shipping methods). Each of the 4 outcomes, results in a different price. When you change the shipping type and check/uncheck the box the total shipping value should change accordingly (as it does with the second link).

    https://www.fooshenergy trial.com/buy1_try3/orderpage2.php (not working)

    https://www.fooshenergy trial.com/orderpage.php (working)



    On a side note, if there are any caffeine fiends among the ranks here, I would be happy to send out some complimentary product for some basic assistance with this site. I get the feeling that its pretty simple and most of you guys could probably write it in your sleep.

    Thanks,

    Andrew
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I (i.e. FireBug/Error console) noticed 3 things:
    1. syntax error on line 140 (")" instead of "}")
    2. MM_preloadImage s is not defined
    3. billTotal is not defined (upon using one of the form elements)

    I guess fixing the first error should be sufficient.

    Comment

    • adweaver
      New Member
      • Oct 2009
      • 20

      #3
      Dorm, you rock.

      I had some trouble finding what you were talking about until I installed FF and ran that error console.

      Thanks for coming through for me.

      A

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        Thanks for coming through for me.
        and that without coffee! ;)

        Comment

        • adweaver
          New Member
          • Oct 2009
          • 20

          #5
          Hey Dorm,

          Any idea why my form calculator initializes with only one decimal place? If I make any changes, it goes to 2 decimal places (even if I reverse the change after), but when the page initially loads, the 39.90 default price shows up as 39.9.

          Code:
          <input name="gtotal" id="gtotal" value="<?php echo $_POST["gtotal"]; ?>" readonly="readonly" type="text" class="graynav" style="width:50px; border:0px;">
          Thanks for the help.
          Andrew

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            do you make the changes via JavaScript?

            Comment

            • adweaver
              New Member
              • Oct 2009
              • 20

              #7
              I don't think so. gtotal looks like this

              Code:
              $_POST["gtotal"]        = mysql_result($resSelect, 0, "Amount");
              	if($_POST["gtotal"] == 49.90) 
              	{
              		$_POST["ship_method"] == "1"; 
              		$checked = "";
              	}
              	else if($_POST["gtotal"] == 54.90) 
              	{
              		$_POST["ship_method"] == "2";
              		$checked = "";
              	}
              	else if($_POST["gtotal"] == 52.90) 
              	{
              		$_POST["ship_method"] == "1"; 
              		$checked = "checked='checked'";
              	}
              	else if($_POST["gtotal"] == 57.90) 
              	{
              		$_POST["ship_method"] == "2"; 
              		$checked = "checked='checked'";
              	}
              	$sqlDelete    = "DELETE FROM tbl_user_info WHERE id=".$hdnId ;
              	$resDelete    = mysql_query($sqlDelete);
              }
              Last edited by Dormilich; Jan 21 '10, 09:39 PM. Reason: removed unnecessary space

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                if gtotal is a number (not a string) unnecessary 0 are removed.

                Comment

                • adweaver
                  New Member
                  • Oct 2009
                  • 20

                  #9
                  is there any way to force the second decimal place?

                  Comment

                  • Dormilich
                    Recognized Expert Expert
                    • Aug 2008
                    • 8694

                    #10
                    use a string, e.g. "52.90" or number_format().

                    Comment

                    Working...