Home › Forums › Quform WordPress › total calculation and sending
- This topic has 3 replies, 2 voices, and was last updated 1 year, 9 months ago by Ally.
- AuthorPosts
- February 10, 2023 at 7:37 pm #35157markavincimParticipant
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);
});
February 10, 2023 at 7:46 pm #35158markavincimParticipantI 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.
February 10, 2023 at 8:00 pm #35159markavincimParticipantMaybe 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();
});
});
February 13, 2023 at 10:40 am #35164AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- AuthorPosts
- You must be logged in to reply to this topic.