Calculation of three select menu values.

Home Forums Quform WordPress Calculation of three select menu values.

This topic is: not resolved
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #26056
    Eitel
    Participant

    Good day Support Team

    I have created a multi-page form with 3 select menus on page 2. The total amount of the 3 select menus must be added in order to display the total. The 3 menu id’s are .quform-field-1_3, .quform-field-1_121 and
    .quform-field-1_34

    I have created the html for the “Form Total” on the page and it shows Total: R0. (R is the currency symbol)

    The value of the items in the first select menu are 0, 705, 907 etc.

    In order to do the calculations I have added the following JavaScript in the Settings.

    jQuery(function ($) {
    var calculate = function () {
    var total = 0;

    // Check the selected option of a select menu
    var val1 = $(‘.quform-field-1_3’).val();
    if (val1 == ‘Option 0’) {
    total +=0;
    } else if (val1 == ‘Option 1’) {
    total +=705;
    } else if (val1 == ‘Option 2’) {
    total +=907;
    }

    // Check the selected option of a select menu
    var val1 = $(‘.quform-field-1_121’).val();
    if (val1 == ‘Option 0’) {
    total += 750;
    } else if (val1 == ‘Option 1’) {
    total += 850;
    } else if (val1 == ‘Option 2’) {
    total += 950;
    }

    // Check the selected option of a select menu
    var val1 = $(‘.quform-field-1_34’).val();
    if (val1 == ‘Option 0’) {
    total += 0;
    } else if (val1 == ‘Option 1’) {
    total += 0;
    } else if (val1 == ‘Option 2’) {
    total += 950;
    }

    // Display the result to the user
    $(‘#form-total’).text(‘Total: R’ + total);

    // Set the value of the hidden field
    $(‘.quform-field-1_9’).val(‘R’ + total);
    };

    // Calculate on page load
    calculate();

    // Recalculate when these select menus are changed
    $(‘.quform-field-1_3, .quform-field-1_121’).change(calculate);

    // Recalculate when these select menus are changed
    $(‘.quform-field-1_3, .quform-field-1_34’).change(calculate);

    // Recalculate when these select menus are changed
    $(‘.quform-field-1_3, .quform-field-1_4’).change(calculate);
    });

    No calculations are however made on the actual WordPress page. Kindly have a look at my JS and help me as I am not experienced in JS.

    I am attaching a screenshots of the 3 select menus as I am not sure whether I have added the values.properly.

    Thank you

    Kind regards

    Eitel

    Attachments:
    You must be logged in to view attached files.
    #26099
    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. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy