Multiply Textfield Input x 3

Home Forums Quform WordPress Multiply Textfield Input x 3

This topic is: not resolved

This topic contains 3 replies, has 2 voices, and was last updated by  Ally 20 hours, 23 minutes ago.

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.