Home › Forums › Quform WordPress › Calculation Question › Reply To: Calculation Question
May 28, 2020 at 7:59 pm #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);
});