Adding custom % rate to dynamic total

  • Profile Image
    Brady
    Asked on July 31, 2011 at 03:25 PM

    Hey there, I'm trying to come up with a way to include an equation that would add a 25% increase to my order forms grand total if the sub total is greater than $90.

     

    So far this is the code I came up with :(but its not working)

     

    /**
         * Calculates the payment total with quantites
         * @param {Object} prices
         */
        
    countTotal: function(prices){
        
            var 
    total 0;
            
    $H(prices).each(function(pair){
                
    total parseFloat(total);
                var 
    price parseFloat(pair.value.price);
                if ($(
    pair.key).checked) {
                    if ($(
    pair.value.quantityField)) {
                        
    price price parseInt($(pair.value.quantityField).getSelected().text10);
                    }
                    
    total += price;
                }
            });
            
            if (
    total === 0) {
                
    total "0.00";
               }
         else if (
    total 90){
                
    total += (total .25);
           }
            if ($(
    "payment_total")) {
                $(
    "payment_total").update(parseFloat(total).toFixed(2));
            }
        },
        
    /**
         * Sets the events for dynamic total calculation
         * @param {Object} prices
         */
        
    totalCounter: function(prices){
            
    $H(prices).each(function(pair){
                $(
    pair.key).observe('click', function(){
                    
    JotForm.countTotal(prices);
                });
                if ($(
    pair.value.quantityField)) {
                    $(
    pair.value.quantityField).observe('change', function(){
                        $(
    pair.key).checked true;
                        
    JotForm.countTotal(prices);
                    });
                }
            });
        }, 

  • Profile Image
    mliz
    Answered on August 02, 2011 at 02:03 AM

    Hi Brady,

    As much as we want to help you the custom script which you are trying to
    implement involves advanced knowledge on scripting.

    For now what I can suggest is for you to download the full source code of the
    form so that you have an idea on what are the variables used for the fields.
    You may also want to post it on several scripting forums on the internet and
    hopefully someone can be able to post a helpful insight on your code.

    Thanks for using JotForm.

    Regards,
    Mliz