Home › Forums › Quform WordPress › Multiply Textfield Input x 3
- This topic has 3 replies, 2 voices, and was last updated 5 years, 5 months ago by Ally.
- AuthorPosts
- October 11, 2018 at 3:33 pm #27162bruellerwerbungParticipant
Hey,
I’m pretty new to JavaScript Coding and was wondering if anyone here could help me out.
I want to multiply the input of a Textfield with 3.
Example:
“Question: How many Customers do you want to be served?
Answer (Textfield): 3
Result: 9”This is the Code I’m trying to work with:
`// A text input field with numeric value
var val4 = $(‘.quform-field-1_8’).val();
if (val4 && val4.length && $.isNumeric(val4)) {
total += parseFloat(val4);
}// Display the result to the user
$(‘#form-total’).text(‘Total: $’ + total);// Set the value of the hidden field
$(‘.quform-field-1_9’).val(‘$’ + total);
};`I’m pretty lost and don’t really know where to put the multiplication..
Thank you in advance!!
Attachments:
You must be logged in to view attached files.October 14, 2018 at 3:15 pm #27188AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
October 15, 2018 at 1:10 pm #27205bruellerwerbungParticipantThank you so, so much, that worked perfectly fine!
I have another little Question though:
Since we are calculating prices, it would be awesome if the results would always been shown with two decimals (Like 17.50 instead of 17.5) – Would this possible?
Attachments:
You must be logged in to view attached files.October 15, 2018 at 1:33 pm #27207AllySupport 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.