• Resolved alphi

    (@alphi)


    Hi!

    The first field in my form is a dropdown in which you select your country. Depending on the choice, a specific value is passed to an equation in a Calculated Field. This works perfectly …. BUT …. I have another Calculated Field to which I want to pass another value (again dependent on the country selected). How can I do this without having to use two dropdown fields?

    Thanks

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

    (@codepeople)

    Hello,

    I’m sorry, but I’m not sure about your question.

    Assuming that a country represents a value for a calculated field and another value for another calculated field, an alternative would be define a global javascript object with countries and properties, and use the corresponding property depending on the equation:

    – Insert a the DropDown field (the fieldname1) with the choices:

    First choice:
    Text: United State
    Value: US

    Second Choice:
    Text: United Kingdom
    Value: UK

    Third Choice:
    Text: Spain
    Value: SP

    – Insert a “HTML Content” field (the fieldname2) to define the global object, similar to:

    <script>
    db = {
    'US':{'property_a': 56, 'property_b': 38},
    'UK':{'property_a': 12, 'property_b': 86},
    'US':{'property_a': 67, 'property_b': 53}
    };
    </script>

    – Now in the first equation use the “property_a”:

    (function(){
    var value = db[fieldname1]['property_a'];
    
    /** the test of code of the equation using the value here **/
    })()

    – and in the second equation the “property_b”:

    (function(){
    var value = db[fieldname1]['property_b'];
    
    /** the test of code of the equation using the value here **/
    })()

    Note: The fields names and values are hypothetical only to explain the process.

    Best regards.

    Thread Starter alphi

    (@alphi)

    Brilliant – Thanks! You understood my question perfectly!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multiple values per Dropdown selection’ is closed to new replies.