Home › Forums › Quform WordPress › Multiply two fields and give total value
- This topic has 2 replies, 2 voices, and was last updated 1 year, 11 months ago by Dylan Scholtz.
- AuthorPosts
- December 2, 2022 at 7:04 am #34987Dylan ScholtzParticipant
Hi
I am trying to get 2 numeric value fields multiply and give a sqm total.
I am currently using the below script from other topics but it only adds up.
jQuery(function ($) {
var calculate = function () {
var total = 0;// A text input field with numeric value
var val4 = $(‘.quform-field-3_38’).val();
if (val4 && val4.length && $.isNumeric(val4)) {
total += parseFloat(val4);
}
// A text input field with numeric value
var val4 = $(‘.quform-field-3_40’).val();
if (val4 && val4.length && $.isNumeric(val4)) {
total += parseFloat(val4);
}// Display the result to the user (optional)
$(‘#form-total’).text(‘Total: sqm’ + total) ;// Set the value of the hidden field (optional)
$(‘.quform-field-3_111’).val(‘sqm’ + total).triggerHandler(‘change’);
};// Calculate on page load
calculate();// Recalculate when these text input fields are changed
$(‘.quform-field-3_38, .quform-field-3_40’).on(‘keyup blur’, calculate);
});I saw the one topic of how to multiply by 3 but I want the fields to multiply each other and give a total.
And then another thing that I want to accomplish is to add a minimum limit to the total value field for example.
The fields that multiplies gives a total sqm and that total needs to be above 450sqm and if it is not above that value the user must not be able to submit the form.
And then one last thing I want is to get the ‘sqm’ behind the total value please if possible.
December 2, 2022 at 9:37 am #34990AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
December 2, 2022 at 10:29 am #34991Dylan ScholtzParticipantHi Ally
Awesomeness, thank you very much it works perfectly.
- AuthorPosts
- You must be logged in to reply to this topic.