• Resolved inicolabug

    (@inicolabug)


    Hi i’m trying to make a quotation form but i can’t figure out how to make the equations i have fieldname 1 dropdown menu and fieldname 2 dropdown menu when fieldname 1 choice1 + fieldname 2 choice 1 = fieldname x (hidden field ) with € value and the other 10 fields with radio buttons yes and no and each fields if is yes and a certain % to the previous values (fieldname x) and at the end a calculation to ad taxes and accessories to the final values.
    i hope u can help me to create the correct equations with calculations and right conditionals thank u in advance Ciao Nicola

    https://www.ads-software.com/plugins/calculated-fields-form/

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

    (@codepeople)

    Hi Nicola,

    In reality with the project’s description you sent me I cannot help you very much.

    However, assuming that the first drop-down field is the fieldname1, and the second drop-down field is the fieldname2, and the values of choices are numbers, furthermore, assuming that the hidden field is the fieldname3, and its value is a number too, and finally, I’ll assume that radio buttons fields are the:

    fieldname4
    fieldname5
    fieldname6
    fieldname7
    fieldname8
    fieldname9
    fieldname10
    fieldname11
    fieldname12
    fieldname13

    and the values of their choices are 0, and 1, and its texts: No and Yes, respectively.
    In my demo I will suppose that 6 “yes” represent a 10% of discount, 7 a 15%, 8 a 20%, 9 a 25%, and 10 a 30%

    The equation would be:

    (function(){
    var result = (fieldname1+fieldname2)*fieldname3;
    var radioBtns = fieldname4+fieldname5+fieldname6+fieldname7+fieldname8+fieldname9+fieldname10+fieldname11+fieldname12+fieldname13;
    
    if(radioBtns == 6) result *= 0.9;
    if(radioBtns == 7) result *= 0.85;
    if(radioBtns == 8) result *= 0.8;
    if(radioBtns == 9) result *= 0.75;
    if(radioBtns == 10) result *= 0.7;
    
    return result;
    })()

    The support service does not include the implementation of the users projects, however, if you need additional help, we can offer you a custom coding service through our personal support page:

    https://cff.dwbooster.com/customization

    Best regards.

    Thread Starter inicolabug

    (@inicolabug)

    Hi thanks for the super fast answer, now i try ur code adding the right values.
    So to explain better yes fieldname 1 (dropdown with 5 different choice, with no number value ) + fieldname 2 (dropdown with 6 different choice, with no number value ) = base result (don’t need to be showed and i already know the value ) then 10 radio button with yes or no .
    so i need to create a calculation fields for every result from fieldname 1 + fieldname 2 ?
    Thanks again for ur great help

    Plugin Author codepeople

    (@codepeople)

    Hi,

    Not really, you need only one calculated field with all mathematical operations, similar to the equation included in the previous ticket.

    Best regards.

    Thread Starter inicolabug

    (@inicolabug)

    ok perfect so i reply the function inside the same calculation filed for each result of the fieldname 1 + fieldname 2 ?
    Just to understand how this funcion get the fieldname 3? (function(){
    var result = (fieldname1+fieldname2)*fieldname3;

    return result;
    })()

    to get the fieldname 3 result i need to select fieldname 1 choice 1 and fieldname 2 choice 1 , how i can configure this ?
    because then i have fieldname 1 choice 1 + fieldname 2 choice 2 and get another result(an hidden fieldname with a number value.
    Thanks if i understand this maybe i can set a right equation

    Plugin Author codepeople

    (@codepeople)

    Hi,

    I’m sorry, my mistake, your initial hidden field was the calculated field, so the equation would be simpler:

    (function(){
    var result = fieldname1+fieldname2;
    var radioBtns = fieldname4+fieldname5+fieldname6+fieldname7+fieldname8+fieldname9+fieldname10+fieldname11+fieldname12+fieldname13;
    
    if(radioBtns == 6) result *= 0.9;
    if(radioBtns == 7) result *= 0.85;
    if(radioBtns == 8) result *= 0.8;
    if(radioBtns == 9) result *= 0.75;
    if(radioBtns == 10) result *= 0.7;
    
    return result;
    })()

    Best regards.

    Thread Starter inicolabug

    (@inicolabug)

    sorry but i think there is a mistake the calculation field isn’t hidden , the hidden fields are the fields with the result from , fieldname 1 choice 1 + fieldname 2 choice 1 ; then fieldname 1 choice 1 + fieldname 2 choice 2 ; then fieldname 1 choice 1 + fieldname 2 choice 3 ; and so on ,
    maybe i think i need an if fieldname 1 is 1 and fieldname 2 is 1 result fieldname 3 (hidden fields with number value) and then if fieldname 1 is 1 and fieldname 2 is 2 result fieldname 4 and so on . right? ??

    Plugin Author codepeople

    (@codepeople)

    Hi,

    In reality you don’t need an additional calculated field to get the sum of fieldname1+fieldname2, because it can be part of the final equation, however, you are free to implement your form as you want, but additional calculated fields increase the complexity and the performance worsens.

    Best regards.

    Thread Starter inicolabug

    (@inicolabug)

    here the mistake i didn’t need a sum of fieldname 1 + fieldname 2 but the selection of fieldname 1 choice 1 + fieldname 2 choice 1 need to recall an hidden field with the result and the calculation need to take the hidden field value to add the radio button options.
    here https://www.bsabroker.info/prev-test-12-may/ a test with ur code that work but i have the sum.
    For this reason i think i need to add an if fieldname 1 is 1 and fieldname 2 is 1 result fieldname 3 (hidden fields with number value).
    but i can do in another way maybe i’ll try …. i’ll let u know later if works

    Plugin Author codepeople

    (@codepeople)

    Hi,

    In this case you don’t need any hidden field, you simply need to use conditional statements to check the values of the fields: fieldname1 and fieldname2, and define a value in function to the selection.

    var result = 0;
    if( fieldname1=="value X" && fieldname2=="value X") result="value A";
    if( fieldname1=="value X" && fieldname2=="value Y") result="value B";
    ....

    Best regards.

    Thread Starter inicolabug

    (@inicolabug)

    ah perfect thanks

    Thread Starter inicolabug

    (@inicolabug)

    i’ll try something like this :

    (function(){
    var result = 0;
    if( fieldname1==”value X” && fieldname2==”value X”) result=”value A”;
    if( fieldname1==”value X” && fieldname2==”value Y”) result=”value B”;

    var radioBtns = fieldname4+fieldname5+fieldname6+fieldname7+fieldname8+fieldname9+fieldname10+fieldname11+fieldname12+fieldname13;

    if(radioBtns == 6) result *= 0.9;
    if(radioBtns == 7) result *= 0.85;
    if(radioBtns == 8) result *= 0.8;
    if(radioBtns == 9) result *= 0.75;
    if(radioBtns == 10) result *= 0.7;

    return result;
    })()

    Thread Starter inicolabug

    (@inicolabug)

    ok i tested just the first step fieldname 1 and fieldname 2 but i have always 0 for result , i did this
    (function(){
    var result = 0;
    if( fieldname1==”value 1″ && fieldname2==”value 1″) result=”value 184,10″;
    if( fieldname1==”value 1″ && fieldname2==”value 2″) result=”value 329,00″;

    return result;
    })()

    maybe i need to define the value of the var result not zero but the value of the conditionals, i’m asking how ? i hope start to work so i stop to annoying you . Thanks again for ur golden support

    Plugin Author codepeople

    (@codepeople)

    Hi,

    Yes, but remember to replace the texts:

    value A, value B, value X, and value Y, by the real values of the fields, and if the values are numbers, you should not close them between double quotes.

    Best regards.

    Thread Starter inicolabug

    (@inicolabug)

    ok i did in this way:

    (function(){
    var result = 0;
    if( fieldname1==”value 1″ && fieldname2==”value 1″) result= value 184,10;
    if( fieldname1==”value 1″ && fieldname2==”value 2″) result= value 329,00;
    var radioBtns = fieldname5;

    if(radioBtns == 6) result *= 0.9;
    return result;
    })()
    but no result from calculations ….. where is the error?
    and in the radio buttons cal when i define the conditional — if(radioBtns == 6) result *= 0.9; — i have to do in this way ? or
    (fieldname5 == 6) result *= 0.9; ??
    thanks again ??

    Thread Starter inicolabug

    (@inicolabug)

    in the radio i need to add a 10% to the result , so result *= 0.9; is right?

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘equations with calculations and conditionals’ is closed to new replies.