This topic is: not resolved
- This topic has 1 reply, 2 voices, and was last updated 5 years, 8 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
Home › Forums › Quform WordPress › Calc problems
Hi,
i try to make a calc process. The goal is:
if one option from multi select is selected, the price is 15,
if 2 options from multi select is selected, the price is 30,
if 3 options from multi select is selected, the price is 45,
if all option from multi select is selected, the price is 55,
Here is the code i wrote. It does not work:
jQuery(function ($) {
var calculate = function () {
var total = 0;
// Check the selected options of a multi select menu
var val1 = $(‘.quform-field-2_34’).val();
if (val1) {
if ($.inArray(‘opt1’, val1) = 1) {
total += 15;
}
if ($.inArray(‘opt2’, val1) = 1) {
total += 30;
}
}
if ($.inArray(‘opt2’, val1) = 3) {
total += 45;
}
if ($.inArray(‘opt2’, val1) = 4) {
total += 55;
}
}
// Display the result to the user
$(‘#form-total’).text(‘Total: $’ + total);
// Set the value of the hidden field
$(‘.quform-field-2_38’).val(‘$’ + total);
};
// Calculate on page load
calculate();
// Recalculate when these select menus are changed
$(‘.quform-field-2_34’).change(calculate);
});
Thank your for your help.
Best regards
You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.