Calc problems

Home Forums Quform WordPress Calc problems

This topic is: not resolved

This topic contains 1 reply, has 2 voices, and was last updated by  Ally 1 day, 5 hours ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #30057

    soylatino
    Participant

    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

    #30089

    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Be inspired. © 2019 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy