• Resolved alphagoldafrica

    (@alphagoldafrica)


    Hi,

    On my form, I have two fields namely, Passengers – Hawker (fieldname12) and Passengers – Challenger (fieldname23).

    I would like to create a formula where for example a user chooses a hawker aircraft (fieldname8) and chooses a seat on the hawker (fieldname9), then only passengers – hawker (fieldname12) will pop up.

    I currently have it setup whereby if a user chooses a hawker aircraft (fieldname8) and chooses a seat on the hawker (fieldname9), then both passengers – hawker (fieldname12) and passengers – challengers fieldname23 pop up.

    Thank you,

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

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

    (@codepeople)

    Hello @alphagoldafrica

    If you need to define dependencies, that depend on multiple fields, you must to use a calculated field as auxiliary.

    For example, you can to insert a calculated field in the form with the formula:

    
    (function(){
    var result = 0
    if(fieldname9 == 'A Seat'){
       if(fieldname8 == 'Hawker HS800xp') result = 1;
       else result = 2;
    }
    return result;
    })()
    

    and finally, you should to remove the dependencies from the fieldname9 field, and define them in this calculated field, as follows:

    – if value is equal to 1 then display the fieldname12
    – if value is equal to 2 then display the fieldname23

    Note: as the calculated field would be used as auxiliary, you can tick the checkbox in its settings for hiding the field from the public form.

    Best regards.

    Thread Starter alphagoldafrica

    (@alphagoldafrica)

    Thank you,

    I have two calculated fields. One calculated field calculates the value as follows:

    (function(){
    if(fieldname8==’Hawker HS800xp’){
    if(fieldname9 == ‘An Aircraft’) return 5000;
    else return fieldname29*1000;
    }
    /** Here the other conditional statements **/
    if(fieldname8==’Challenger CL604′){
    if(fieldname9 == ‘An Aircraft’) return 6000;
    else return fieldname29*750;
    }
    /** Here the other conditional statements **/
    if(fieldname8==’Other Private Jets’){
    if(fieldname9 == ‘An Aircraft’) return 1;
    else return fieldname29*1;
    }
    /** Here the other conditional statements **/
    })()

    The second calculated field is the auxiliary field you recommended above with dependencies.

    (function(){
    var result = 0
    if(fieldname9 == ‘A Seat’){
    if(fieldname8 == ‘Hawker HS800xp’) result = 1;
    else result = 2;
    }
    return result;
    })()

    The price for ‘A Seat’ is not calculated with the auxillary field. What’s wrong?

    Plugin Author codepeople

    (@codepeople)

    Hello @alphagoldafrica

    My mistake, I’ve forgotten the semicolon sign at the end of the line of code:

    
    var result = 0;
    

    The correct would be:

    
    (function(){
    var result = 0;
    if(fieldname9 == 'A Seat'){
       if(fieldname8 == 'Hawker HS800xp') result = 1;
       else result = 2;
    }
    return result;
    })()
    

    Best regards.

    Thread Starter alphagoldafrica

    (@alphagoldafrica)

    Absolutely splendid! Wow…thank you very very much. Amazing :-). You are indeed a star

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Need help with a conditional formula’ is closed to new replies.