Home › Forums › Quform WordPress › Calculation not being able to mak it work
- This topic has 4 replies, 3 voices, and was last updated 8 years, 1 month ago by Ally.
- AuthorPosts
- March 14, 2016 at 11:07 pm #18405chipotlexParticipant
Hi, first of all great plugin! works beautifuly!
However i’ve tried to follow calulation example to sum some checkboxes instances and one radio button instance without success.
The total variable is not being modyfied also i can get it not printed in the form nor the email.
I wrote the modification in dreamweaver for easy to use an keep record, i sanitized some trailing space errors i got from JSLint and I’ve checked my unique fields IDs and i think they are all correct.
I’ll appreciate your review and suggestions, Below is my code:<div id=”form-total”></div>
<script>
jQuery(document).ready(function ($) {
var calculate = function () {
var total = 0.00;//1 **** 8:00 – 9:00 *****
//Checkbox YOG
if ($(‘.iphorm_1_5_1’).is(‘:checked’)) { total += 600.00;
}//2 **** 10:00 – 11:00 *****
//Checkbox CAP
if ($(‘.iphorm_1_21_1’).is(‘:checked’)) { total += 1500.00;
}// Checkbox JAR
if ($(‘.iphorm_1_21_2’).is(‘:checked’)) { total += 600.00;
}//3 **** 11:00 – 12:30 *****
//Checkbox DAN
if ($(‘.iphorm_1_20_1’).is(‘:checked’)) { total += 1100.00;
}//Checkbox LEO
if ($(‘.iphorm_1_20_2’).is(‘:checked’)) { total += 600.00;
}//Checkbox PER
if ($(‘.iphorm_1_20_3’).is(‘:checked’)) { total += 600.00;
}//4 **** 12:30 – 2:00 *****
// Checkbox DAN
if ($(‘.iphorm_1_19_1’).is(‘:checked’)) { total += 1100.00;
}//Checkbox REQ
if ($(‘.iphorm_1_19_2’).is(‘:checked’)) { total += 600.00;
}//Checkbox BALA
if ($(‘.iphorm_1_19_3’).is(‘:checked’)) { total += 1100.00;
}//5 **** 3:00 – 4:30 *****
//Checkbox PERCU
if ($(‘.iphorm_1_18_1’).is(‘:checked’)) { total += 900.00;
}//Checkbox ZAPA
if ($(‘.iphorm_1_18_2’).is(‘:checked’)) { total += 600.00;
}//6 **** 4:30 – 6:00 *****
//Checkbox DANZ
if ($(‘.iphorm_1_17_1’).is(‘:checked’)) { total += 900.00;
}//Checkbox CAPR
if ($(‘.iphorm_1_17_2’).is(‘:checked’)) { total += 1500.00;
}//7 **** 6:00 – 7:30 *****
//Checkbox DANAF
if ($(‘.iphorm_1_16_1’).is(‘:checked’)) { total += 1100.00;
}//Checkbox CANAF
if ($(‘.iphorm_1_16_2’).is(‘:checked’)) { total += 600.00;
}//8 **** 7:30 – 9:00 *****
// Checkbox DANDUN
if ($(‘.iphorm_1_14_1’).is(‘:checked’)) { total += 900.00;
}//9 **** 9:00 – 10:30 *****
// Checkbox DANVA
if ($(‘.iphorm_1_15_1’).is(‘:checked’)) { total += 1100.00;
}//**** PAQS *****
//Radio buttons
var val3 = $(‘.iphorm_1_22:checked’).val(); if (val3 == ‘Option 1’) {
total += 2200.00;
} else if (val3 == ‘Option 2’) {
total += 1700.00;
} else if (val3 == ‘Option 3’) {
total += 1200.00;
} else if (val3 == ‘Option 4’) {
total += 750.00;
}//Display the result to the user
$(‘#form-total’).text(‘Total: $’ + total);// et the value of the hidden field
$(‘input[name=iphorm_1_26]’).val(‘$’ + total); };//Calculate on page load
calculate();//Recalculate when these checkboxes/radio buttons are clicked
$(‘.iphorm_1_21, .iphorm_1_20, .iphorm_1_19, .iphorm_1_18, .iphorm_1_17, .iphorm_1_16, .iphorm_1_15, .iphorm_1_14, .iphorm_1_5,’).click(calculate);</script>
March 19, 2016 at 8:26 pm #18436AllanSupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
March 21, 2016 at 10:25 am #18447AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
March 21, 2016 at 11:15 pm #18472chipotlexParticipantHi Alli
It is working now, thanks a lot! However i have one last issue:Calculation is not being updated when checkboxes are clicked but only when the page is reloaded, but radiobuttons are not added to my calculation only the checkboxes.
Here is the link: http://tiny.cc/3kn89x
I Appreciate your support!
March 23, 2016 at 4:16 pm #18493AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- AuthorPosts
- You must be logged in to reply to this topic.