Multiply Textfield Input x 3

Home Forums Quform WordPress Multiply Textfield Input x 3

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

    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.
    #27188
    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.

    #27205
    bruellerwerbung
    Participant

    Thank 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.
    #27207
    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