• Resolved serkanyaman

    (@serkanyaman)


    Hi everyone, I’m trying to build a form that gives an average price for second-hand phones. I’m adding the required for all fields but when i click on the calculate button it gives the price even if the fields are empty. I work a lot for this problem but I couldn’t solve it. If you can help me I’ll be really appreciate. Thank you so much.

    https://ibb.co/ZM7GNvN

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @serkanyaman

    Thank you very much for using our plugin. You can use conditional statements or conditional operations in the equation.

    I’ll try to describe the process with a hypothetical example.

    Assuming you have three fields, fieldname1, fieldname2, and fieldname3 and you want to calculate the average. The basic equation would be:

    AVERAGE(fieldname1, fieldname2, fieldname3)

    But if you want to evaluate it only after the user enter the fields’ values, you should edit the equation as follows:

    IF(AND(fieldname1, fieldname2, fieldname3), AVERAGE(fieldname1, fieldname2, fieldname3), '')

    If you prefer to implement the equation with function structure and the “if” conditional statement instead of the “IF” operation, it would be:


    (function(){
    if(AND(fieldname1, fieldname2, fieldname3))
    return AVERAGE(fieldname1, fieldname2, fieldname3);
    })()

    Best regards.

    Thread Starter serkanyaman

    (@serkanyaman)

    Hi, thank you for your precious message. Now my form is working as i wanted. Now when we click the calculate button it’s not calculate the form before all the fields entered. But even the one field is not entered it’s not calculating, but also not giving any warning. Is there any way to show/trigger plugin’s own required warning?

    my calculate code is like this:

    var phone = fieldname1;
    var minussum = fieldname2 + fieldname3 + fieldname4 + fieldname5 + fieldname6;
    var total = telefon – eksitoplam;

    (function(){
    if(AND(fieldname1, fieldname2, fieldname3,fieldname4,fieldname5,fieldname6))
    return total;
    })()

    • This reply was modified 6 months, 2 weeks ago by serkanyaman.
    Plugin Author codepeople

    (@codepeople)

    Hello @serkanyaman

    Assuming you have the equation:


    (function(){
    var phone = fieldname1;
    var minussum = fieldname2 + fieldname3 + fieldname4 + fieldname5 + fieldname6;
    var total = telefon – eksitoplam;

    if(AND(fieldname1, fieldname2, fieldname3,fieldname4,fieldname5,fieldname6))
    return total;
    })()

    And you want to validate the fields displaying the corresponding error messages before evaluating the equation. You can edit the equation as follows:


    (function(){
    var phone = fieldname1;
    var minussum = fieldname2 + fieldname3 + fieldname4 + fieldname5 + fieldname6;
    var total = telefon – eksitoplam;

    if(AND(VALIDFIELD(fieldname1|n), VALIDFIELD(fieldname2|n), VALIDFIELD(fieldname3|n),VALIDFIELD(fieldname4|n),VALIDFIELD(fieldname5|n),VALIDFIELD(fieldname6|n)))
    return total;
    })()

    Learn more about the “Managing Fields Operations” module by reading the following section in the plugin documentation:

    https://cff.dwbooster.com/documentation#managing-fields-module

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Calculate Type of Button Field Isn’t Work Properly’ is closed to new replies.