Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript downloadable order form, having problems coding decimals

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #24285
    zzzCL
    Member

    Hello,

    Hopefully someone can help me here, i recently downloaded the template from this site for the Order form Chris did recently and im having a slight issue, the prices that i have recently changed in the HTML code, has been changed to decimal’s, so basically cents in some cases instead of dollars. The java will calculate the decimals in the row totals for the products, but then it comes to the sub total and grand total, it decides to not include a decimal and round to a whole number, with the industry i work for and am currently designing a site for them, i was wondering if anyone could help me, I’m not sure exactly what part of the code you would need as i am not that fluent with Java, but any help would be greatly appreciated, if you need the code let me know with your response and i can post it

    Thanks

    zzzCL

    #54701
    zzzCL
    Member

    here is the code, thanks for the quick response it is greatly appreciated.

    Code:
    function IsNumeric(sText)

    {
    var ValidChars = “0123456789.”;
    var IsNumber=true;
    var Char;

    for (i = 0; i < sText.length && IsNumber == true; i++) { Char = sText.charAt(i); if (ValidChars.indexOf(Char) == -1) { IsNumber = false; } } return IsNumber; }; function calcProdSubTotal() { var prodSubTotal = 0; $(".row-total-input").each(function(){ var valString = $(this).val() || 0; prodSubTotal += valString; }); $("#product-subtotal").val(prodSubTotal); }; function calcTotalPallets() { var totalPallets = 0; $(".num-pallets-input").each(function() { var thisValue = $(this).val(); if ( (IsNumeric(thisValue)) && (thisValue != '') ) { totalPallets += thisValue; }; }); $("#total-pallets-input").val(totalPallets); }; function calcShippingTotal() { var totalPallets = $("#total-pallets-input").val() || 0; var shippingRate = $("#shipping-rate").text() || 0; var shippingTotal = totalPallets; $("#shipping-subtotal").val(shippingTotal); }; function calcOrderTotal() { var orderTotal = 0; var productSubtotal = $("#product-subtotal").val() || 0; var shippingSubtotal = $("#shipping-subtotal").val() || 0; var orderTotal = productSubtotal + shippingSubtotal; var orderTotalNice = "$" + orderTotal; $("#order-total").val(orderTotalNice); }; $(function(){ $('.num-pallets-input').blur(function(){ var $this = $(this); var numPallets = $this.val(); var multiplier = $this .parent().parent() .find("td.price-per-pallet span") .text(); if ( (IsNumeric(numPallets)) && (numPallets != '') ) { var rowTotal = numPallets * multiplier; $this .css("background-color", "white") .parent().parent() .find("td.row-total input") .val(rowTotal); } else { $this.css("background-color", "#ffdcdc"); }; calcProdSubTotal(); calcTotalPallets(); calcShippingTotal(); calcOrderTotal(); }); });

    #54730

    Any chance of a live link so we can see the problem in action?

    #54739
    zzzCL
    Member

    The website itself is not live, i can try and access the box i have in Chicago to temporarily host this page, not sure if im going to be able to do that (other owner might get a little upset LOL), in case i cannot, i will update you as to what i have tried, i can now get decimals in the subtotal and the order total, but it adds way to many zeros, both in front of the price, and after it. Sorry if i Dont get a live link up, if not ill screenshot it and post what its doing.

    Thanks for the quick responses guys

    zzzCL

    #54751
    ikthius
    Member

    then why not have a holding page, so that anyone going to the main site, will be directed to that, and show us the page you want help with???

    the client need not know, plus if the client wants it working, and you need help, then they got to be prepared to put up with people seeing the site for helping purposes

    #61628
    danielnevesn
    Member

    You can show a code in which the subtotal showing decimals bandstand?

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.