Calculation Question

Home Forums Quform WordPress Calculation Question

This topic is: resolved
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #31316
    V1DCU
    Participant

    GOT IT WORKING!!!! BUT the hidden field does not show up in the notification email…it is set to though?

    I am trying to add calculations to QuForm and am wondering how this looks?

    I will essentially have something for every roll of coin (Nickles, dimes, quarters, loonie and toonie) I am just struggling the actual code and was wondering if anyone can help!

    I am not certain on the actual code or the total, like how do I wrap it up so that there is one large total or does the code under the “display the result to user” cover all totals?

    I cannot get the hidden field to total up or anything.

    Thank you!!

    Field 5_3 is Nickles @ $2 a roll,
    5_4 is Dimes @ $5 a roll,
    5_5 is Quarters @ $10 a roll
    5_6 is Loonies @ $25 a roll
    5_7 is Toonies @ $50 a roll

    5_9 is the hidden field

    Hidden HTML field with
    <div id="form-total"></div>

    Then this would be going (so far) in the JS area

    jQuery(function ($) {
        var calculate = function () {
            var total = 0;
    
            var val = $('.quform-field-5_3').val();
            if (val && val.length && $.isNumeric(val)) {
                total += parseFloat(val) * 2;
            }
    
           var val = $('.quform-field-5_4').val();
            if (val && val.length && $.isNumeric(val)) {
                total += parseFloat(val) * 5;
            }
    
            var val = $('.quform-field-5_5').val();
            if (val && val.length && $.isNumeric(val)) {
                total += parseFloat(val) * 10;
            }
    
            var val = $('.quform-field-5_6').val();
            if (val && val.length && $.isNumeric(val)) {
                total += parseFloat(val) * 25;
            }
            var val = $('.quform-field-5_7').val();
            if (val && val.length && $.isNumeric(val)) {
                total += parseFloat(val) * 50;
            }
    
            // Set the value of the hidden field
            $('.quform-field-5_9').val('$' + total);
           
        };
     
       
    });

    I just cant seem to get it to generate a total and the HTML shows on the form

    • This topic was modified 3 years, 10 months ago by V1DCU.
    • This topic was modified 3 years, 10 months ago by V1DCU.
    • This topic was modified 3 years, 10 months ago by V1DCU.
    • This topic was modified 3 years, 10 months ago by V1DCU. Reason: Trying to make this as clear as I can!
    • This topic was modified 3 years, 10 months ago by V1DCU. Reason: Adding Photo :)
    • This topic was modified 3 years, 10 months ago by V1DCU.
    • This topic was modified 3 years, 10 months ago by V1DCU.
    Attachments:
    You must be logged in to view attached files.
    #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 3 years, 10 months ago by V1DCU.
    • This reply was modified 3 years, 10 months ago by V1DCU.
    #31343
    V1DCU
    Participant

    I now get an error but the form gets submitted still….

    “There was a problem
    The response from the server was invalid or malformed”

    #31381
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #31394
    V1DCU
    Participant

    Must have been old cookie save din Chrome with the changed I kept making in the JavaScript, working!

    Thank you!!!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy