• Resolved chrimby

    (@chrimby)


    Hello,

    i want to integrate a calculator, that calculates the price of specific things in different combinations.

    For example: if checkbox 1 is activated –> fieldname3+fieldname4
    2nd example: if checkbox 3 is activated –> fieldname2+fieldname4
    3rd example: if checkbox 3&&checkbox 1 are activated –>fieldname2+2*fieldname4+fieldname3

    My problem is, that i haven’t find out yet, how to set up the if conditions. Which values do the checkboxes return when activated/not activated?

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

Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hi,

    Suppose the checkboxes group is named fieldname1. And the values of three choices are: 1, 3 and 5

    So, your equation would be:

    (function(){
    // Only first option selected
    if(fieldname1 == 1) return fieldname3+fieldname4;
    // Only the third option selected
    if(fieldname1 == 5) return fieldname2+fieldname4;
    // If the first and third options are selected 1+5
    if(fieldname1==6) return fieldname2+2*fieldname4+fieldname3;
    })();

Viewing 1 replies (of 1 total)
  • The topic ‘Checkbox Problem’ is closed to new replies.