total calculation and sending

Home Forums Quform WordPress total calculation and sending

This topic is: not resolved
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #35157
    markavincim
    Participant

    Hello,

    I have created a form. There is a score value for the correct answer. I can display the total score on the screen using the following code. But I want to see the total score when all the questions are answered and the submit button is pressed. And I also want the form and the total score to be sent to the administrator.

    Right now the submit button is not working. A message has been sent warning appears. The form is not being sent.

    I will be glad if you help.

    Thank you


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

    // A radio button
    var val3 = $('.quform-field-5_15:checked').val();
    if (val3 == 'enforcement') {
    total += 25;
    } else if (val3 == 'justice') {
    total += 0;
    } else if (val3 == 'courtesy') {
    total += 0;
    } else if (val3 == 'instance') {
    total += 0;
    } else if (val3 == 'fairness') {
    total += 0;
    }

    // B radio button
    var val3 = $('.quform-field-5_15:checked').val();
    if (val3 == 'persuade') {
    total += 25;
    } else if (val3 == 'provide') {
    total += 0;
    } else if (val3 == 'permit') {
    total += 0;
    } else if (val3 == 'preserve') {
    total += 0;
    } else if (val3 == 'promote') {
    total += 0;
    }

    // Display the result to the user (optional)
    $('#form-total').text('Aldığınız Puan:' + total);

    // Set the value of the hidden field (optional)
    $('.quform-field-5_3').val('$' + total).triggerHandler('change');
    };

    $('.quform-field-5_15, .quform-field-5_6').on('click', calculate);

    });

    #35158
    markavincim
    Participant

    I am sorry,

    the form is being submitted, the total value is not visible. I guess I’m making a mistake in the hidden field. It comes as hidden, it doesn’t come with value.

    #35159
    markavincim
    Participant

    Maybe I solved it. I defined the button function and it worked. maybe it will help someone. I leave the codes here.

    I would appreciate if you let me know if there is any mistake.


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

    // A radio button
    var val3 = $('.quform-field-5_15:checked').val();
    if (val3 == 'enforcement') {
    total += 25;
    } else if (val3 == 'justice') {
    total += 0;
    } else if (val3 == 'courtesy') {
    total += 0;
    } else if (val3 == 'instance') {
    total += 0;
    } else if (val3 == 'fairness') {
    total += 0;
    }

    // B radio button
    var val3 = $('.quform-field-5_5:checked').val();
    if (val3 == 'persuade') {
    total += 25;
    } else if (val3 == 'provide') {
    total += 0;
    } else if (val3 == 'permit') {
    total += 0;
    } else if (val3 == 'preserve') {
    total += 0;
    } else if (val3 == 'promote') {
    total += 0;
    }

    // Display the result to the user (optional)
    $('#form-total').text('Aldığınız Puan:' + total);

    // Set the value of the hidden field (optional)
    $('.quform-field-5_3').val('Puan: ' + total).triggerHandler('change');
    };

    $('.quform-button-submit-5_2').on('click', function () {
    calculate();
    });
    });

    #35164
    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 4 posts - 1 through 4 (of 4 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