Reply To: Calculation Question

Home Forums Quform WordPress Calculation Question Reply To: Calculation Question

#31339
V1DCU
Participant

I was able to get it work and have all coins up and running!!

Never written an lick of code in my life – super pumped.

jQuery(function ($) {
    var calculate = function () {
        var total = 0;

       var val = $('.quform-field-4_23').val();
        if (val && val.length && $.isNumeric(val)) {
            total += parseFloat(val) * 2;
        }

       var val = $('.quform-field-4_24').val();
        if (val && val.length && $.isNumeric(val)) {
            total += parseFloat(val) * 5;
        }

       var val = $('.quform-field-4_25').val();
        if (val && val.length && $.isNumeric(val)) {
            total += parseFloat(val) * 10;
        }

       var val = $('.quform-field-4_26').val();
        if (val && val.length && $.isNumeric(val)) {
            total += parseFloat(val) * 25;
        }

       var val = $('.quform-field-4_27').val();
        if (val && val.length && $.isNumeric(val)) {
            total += parseFloat(val) * 50;
        }
       
       var val = $('.quform-field-4_10').val();
        if (val && val.length && $.isNumeric(val)) {
            total += parseFloat(val) * 5;
        }

      var val = $('.quform-field-4_14').val();
        if (val && val.length && $.isNumeric(val)) {
            total += parseFloat(val) * 10;
        }

       var val = $('.quform-field-4_13').val();
        if (val && val.length && $.isNumeric(val)) {
            total += parseFloat(val) * 20;
        }

       var val = $('.quform-field-4_12').val();
        if (val && val.length && $.isNumeric(val)) {
            total += parseFloat(val) * 50;
        }
       var val = $('.quform-field-4_11').val();
        if (val && val.length && $.isNumeric(val)) {
            total += parseFloat(val) * 100;
        }

        $('.quform-field-4_18').val(total);
        $('#form-total').text('Coin order total $: ' + total);
    };

    calculate();
    $('.quform-field-4_23,.quform-field-4_24,.quform-field-4_25,.quform-field-4_26,.quform-field-4_27,.quform-field-4_10,.quform-field-4_14,.quform-field-4_13,.quform-field-4_12,.quform-field-4_11').on('keyup blur', calculate);
});
  • This reply was modified 1 month, 1 week ago by V1DCU.
  • This reply was modified 1 month, 1 week ago by V1DCU.
Be inspired. © 2020 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy