Home › Forums › Quform WordPress › Calculation Question
- This topic has 4 replies, 2 voices, and was last updated 4 years, 6 months ago by V1DCU.
- AuthorPosts
- May 27, 2020 at 10:34 pm #31316V1DCUParticipant
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 roll5_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 4 years, 6 months ago by V1DCU.
- This topic was modified 4 years, 6 months ago by V1DCU.
- This topic was modified 4 years, 6 months ago by V1DCU.
- This topic was modified 4 years, 6 months ago by V1DCU. Reason: Trying to make this as clear as I can!
- This topic was modified 4 years, 6 months ago by V1DCU. Reason: Adding Photo :)
- This topic was modified 4 years, 6 months ago by V1DCU.
- This topic was modified 4 years, 6 months ago by V1DCU.
Attachments:
You must be logged in to view attached files.May 28, 2020 at 7:59 pm #31339V1DCUParticipantI 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); });
May 28, 2020 at 8:48 pm #31343V1DCUParticipantI now get an error but the form gets submitted still….
“There was a problem
The response from the server was invalid or malformed”June 1, 2020 at 11:08 am #31381AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
June 1, 2020 at 4:10 pm #31394V1DCUParticipantMust have been old cookie save din Chrome with the changed I kept making in the JavaScript, working!
Thank you!!!
- AuthorPosts
- You must be logged in to reply to this topic.