What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    Adding custom % rate to dynamic total

    Asked by Brady 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
    JotForm Support

    Answered by mliz 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