I've finished my shipping calculator script, but now for some reason Math.ceil used on "var sum" in my script does the opposite of what it's supposed to! When it's used in an older version of my script it works correctly so I would assume I've done something wrong that's borking the script now.
This script correctly rounds up the totalweight to the next whole number: ------------------------------------------------------------------------------------------------ <html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#calculateweight").click(function() { var sum = 0; $("input[name*='weight']").each(function() { sum += Number($(this).val()); }); $("#totalweight").text( Math.ceil(sum) ); return false; }); }); </script> </script> </head> <body> <form> <input type="hidden" name="weight1" value="1.1"> </form> <button id="calculateweight">Calculate Price</button><br /> Total Weight: <span id="totalweight"></span><br /> </body> </html> --------------------------------------------------------------------------------------------------- My shipping script does the opposite, it always rounds down the total weight even if the result is a whole number: ------------------------------------------------------------------------------------------- <html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function() { var totalweight = 0; var zipcode = 00000; var shortzip = 000; var zonearray = new Array("005-212 8","214-268 8","270-342 8","344-344 8","346-347 8","349-352 8", "354-418 8","420-427 8","430-462 8","463-464 7","465-497 8","498-509 7","510-513 6","514-514 7","515-516 6", "520-528 7","530-532 7","534-535 7","537-551 7","553-561 7","562-562 6","563-563 7","564-567 6","570-576 6", "577-577 5","580-587 6","588-588 5","590-595 5","596-599 4","600-620 7","622-631 7","633-641 7","644-668 7", "699-699 6","670-673 7","674-681 6","683-693 6","700-701 8","703-708 8","710-711 7","712-714 8","716-722 7", "723-723 8","724-731 7","733-735 7","736-736 6","737-737 7","738-739 6","740-741 7","743-769 7","770-772 8", "773-775 7","776-777 8","778-782 7","783-785 8","786-789 7","790-794 6","795-797 7","798-799 6","800-807 5", "808-811 6","812-816 5","820-831 5","832-834 4","835-835 4","836-837 4","838-838 4","840-847 5","850-850 5", "852-853 5","855-855 5","856-857 6","859-860 5","863-865 5","870-872 6","873-874 5","875-875 6","877-885 6", "889-891 5","893-895 4","897-898 4","900-908 5","910-928 5","930-935 5","936-954 4","955-955 3","956-959 4", "960-960 3","961-966 4","967-969 8","970-972 2","973-974 1","975-977 2","978-978 3","979-979 4","980-985 3", "986-986 2","988-989 3","990-992 4","993-993 3","994-994 4","995-997 7","998-998 6","999-999 5"); var zone = 1; var pricesarray = new Array("4.8,4.8,4.8,4.8,4.8,4.8,4.8,4.8",", 4.8,4.8,4.99,5.37,6.67,7.18,7.69,8.3","5.08,5.08,5.81,6.64,8.15,9.35,10.07,11.41", "5.64,5.64,6.6,7.62,9.78,11.29,12.29,14.03","6.33,6.33,7.58,8.55,11.56,12.98,14.43,16.37","6.98,6.98,8.6,9.84,13.34,14.64,16.62,18.71", "7.68,7.68,9.58,11.14,15.23,16.34,18.76,21.04","8.14,8.14,9.95,12.24,16.7,17.76,20.61,23.63","8.37,8.37,10.64,13.04,18,19.18,22.41,26.3", "9.05,9.05,11.49,14.16,19.5,21.26,24.59,28.59","9.76,9.76,12.37,15.33,21.05,23.38,26.78,30.93","10.36,10.36,13.2,16.45,22.56,25.45,28.96,33.22", "10.64,10.64,13.53,16.92,23.78,27.3,30.11,34.36","11.01,11.01,14.14,17.67,24.86,28.82,31.81,36.08","11.47,11.47,14.74,18.55,25.61,29.43,32.14,36.85", "11.84,11.84,15.26,19.12,26.17,30.08,32.86,37.76","12.25,12.25,15.77,19.49,26.78,30.89,33.72,38.75","12.49,12.49,16.27,19.91,27.35,31.51,34.33,39.66", "12.9,12.9,16.65,20.2,28.01,32.26,35.23,40.66","13.23,13.23,16.87,20.57,28.47,32.88,35.9,41.58","13.6,13.6,17.11,20.89,28.94,33.4,36.51,42.38", "13.92,13.92,17.43,21.22,29.6,34.14,37.37,43.44","14.24,14.24,17.67,21.82,30.12,34.76,37.99,44.2","14.57,14.57,17.86,22.48,30.73,35.47,38.89,45.3", "14.89,14.89,18.13,23.23,31.25,35.99,39.45,46.06","15.21,15.21,18.32,23.97,31.91,36.84,40.31,47.53","15.63,15.63,18.6,24.68,32.33,37.36,40.88,49.31", "16.1,16.1,18.82,25.33,32.76,37.88,41.5,51.12","16.61,16.61,19.01,26.09,33.18,38.35,42.07,52.74","17.11,17.11,19.3,26.78,33.64,38.87,42.64,54.5", "17.58,17.58,19.48,27.53,34.07,39.39,43.21,56.31","18.04,18.04,19.94,28.24,34.49,39.92,44.25,58.09","18.27,18.27,20.46,28.88,34.92,40.44,45.48,59.75", "18.45,18.45,21.01,29.39,35.66,41.62,46.72,61.52","18.68,18.68,21.52,29.81,36.42,42.75,48,63.29","18.87,18.87,22.08,30.19,37.22,43.83,49.28,65.06", "19.05,19.05,22.54,30.62,37.92,44.97,50.57,66.82","19.24,19.24,23.1,30.99,38.67,46.25,51.75,68.53","19.47,19.47,23.58,31.36,39.47,47.38,53.09,70.36", "19.84,19.84,24.08,31.69,40.27,48.46,54.27,72.02","20.25,20.25,24.54,32.06,40.64,49.6,55.6,73.41","20.63,20.63,25.02,32.39,41.49,50.68,56.89,74.41", "21.04,21.04,25.43,32.72,42.43,51.91,58.16,75.37","21.41,21.41,25.95,33.05,43.37,52.99,59.44,76.27","21.78,21.78,26.41,33.38,44.31,54.18,60.73,77.17", "22.19,22.19,26.73,33.7,45.15,55.31,61.96,78.04","22.57,22.57,26.91,33.98,46.15,56.54,63.29,78.94","22.98,22.98,27.15,34.31,47.08,57.67,64.57,79.76", "23.36,23.36,27.34,34.59,47.92,58.71,65.91,80.56","23.67,23.67,27.57,34.91,48.87,59.85,66.95,81.57","24.14,24.14,27.76,35.52,49.81,60.98,67.56,82.43", "24.46,24.46,27.94,36.22,50.74,61.69,68.14,83.24","24.92,24.92,28.13,36.83,51.64,62.16,68.71,84.06","25.25,25.25,28.26,37.44,52.63,62.63,69.23,84.86", "25.67,25.67,28.46,38.19,53.56,63.1,69.8,85.58","26.04,26.04,28.6,38.8,54.41,63.57,70.27,86.34","26.45,26.45,28.78,39.4,55.25,64.01,70.8,87.11", "26.83,26.83,28.92,40.1,55.96,64.43,71.27,87.82","27.24,27.24,29.06,40.76,56.34,64.86,71.69,88.44","27.56,27.56,29.2,41.36,56.67,65.23,72.84,89.11", "28.02,28.02,29.29,42.11,56.95,65.99,73.97,90.31","28.35,28.35,29.43,42.72,57.28,66.41,75.12,91.74","28.81,28.81,29.57,43.38,57.56,66.79,75.88,93.17", "29.13,29.13,29.66,44.03,57.84,67.21,76.35,94.64","29.55,29.55,29.75,44.59,58.12,67.55,76.78,96.12","29.92,29.92,30.08,45.29,58.36,67.97,77.15,97.51", "30.34,30.34,30.5,46.04,58.97,68.3,77.59,99.04","30.71,30.71,30.87,46.65,59.81,68.59,77.96,100.42","31.13,31.13,31.29,47.25,60.71,68.96,78.35,101.9", "31.49,31.49,31.66,48,60.99,69.25,78.67,103.33"); var price = 0.00; $("#calculateweight").click(function() { var sum = 0; $("input[name*='weight']").each(function() { sum += Number($(this).val()); }); totalweight = Math.ceil(sum); zipcode = $("#zipcode").val(); shortzip = zipcode.substring(0, 3); var curRangeStart, curRangeEnd; for (var i = 0; i < zonearray.length; i++) { curRangeStart = parseFloat(zonearray[i].substring(0, 3)); curRangeEnd = parseFloat(zonearray[i].substring(4, 7)); if (shortzip >= curRangeStart && shortzip <= curRangeEnd) { zone = parseFloat(zonearray[i].substring(8, 9)); break; } } weightpricearray = (pricesarray[--totalweight]).split(","); price = ("$" + weightpricearray[zone]); $("#sumdisplay").text(sum); $("#totalweight").text(totalweight + "lbs"); $("#zipcodedisplay").text(zipcode); $("#zipdisplay").text(shortzip); $("#zonedisplay").text(zone); $("#pricedisplay").text(price); return false; }); }); </script> </head> <body> <form> <input type="hidden" name="weight1" value="1"> Destination Zipcode:<br /> <input type="text" id="zipcode" value="00000" maxlength="5" size="5"> </form> <button id="calculateweight">Calculate Price</button><br /> Sum: <span id="sumdisplay"></span></br /> Total Weight: <span id="totalweight"></span><br /> Zipcode: <span id="zipcodedisplay"></span><br /> Zip: <span id="zipdisplay"></span><br /> Zone: <span id="zonedisplay"></span><br /> Price: <span id="pricedisplay"></span> </body> </html> --------------------------------------------------------------------------------------------------------------------- Thanks for taking a look, I hope someone can give me some insight as to why this is happening.