• Resolved emilianomaina

    (@emilianomaina)


    Hello,

    I have a form where today a user has to insert three values (a, b, c) that in reality are a Tuple associated to a specifica geographic location.

    I mean:
    Rome => (a1, b1, c1)
    Milan => (a2, b2, c2)
    Venice => (a3, b3, c3)

    I was only able to create 3 inputs and one very simple formula for the result (using also oter input values).
    This make users to make wrong inputs.
    Is there any way to create a dropdown with location choice that selected make a tuple available in the formula?

    Hope I explained my need.

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

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

    (@codepeople)

    Hello @emilianomaina

    Yes, that’s possible. Please, insert a dropdown field in the form with these choices:

    * The following values and fields’ names are hypothetical, only to describe the process

    First choice:
    Text: Rome
    Value: 1,2,3

    Second choice:
    Text: Milan
    Value: 4,5,6

    Third choice:
    Text: Venice
    Value: 7,8,9

    Now, assuming the name of the dropdown field is fieldname1, and you want to get the raw value of the selected choice (without preprocessing). You should refer to the field in the equation with the |r modifier. For example, insert a calculated field in the form with the equation:

    fieldname1|r

    Of course, you should use in the equation the name of the dropdown field in your form.

    Best regards.

    Thread Starter emilianomaina

    (@emilianomaina)

    Thanks for the prompt reply.

    Not clear how, in the equation, access to the single field returned by the selected choice.

    Plugin Author codepeople

    (@codepeople)

    Hello @emilianomaina

    I’m sorry, but I don’t understand what you want to do. You asked me about using a dropdown field with tuples as the values of your options.

    Best regards.

    Thread Starter emilianomaina

    (@emilianomaina)

    Let me try to clariy.

    Choosing the dropdown I have the tuple (a, b, c).
    In another place I collect inputs d and e.

    How can I access in the equation to single fields ?

    I mean to crate a formula like (a-d)/(b-e)+c as an example.

    PS I don’t understand the meaning of this syntax fieldname1|r

    Plugin Author codepeople

    (@codepeople)

    Hello @emilianomaina

    The plugin tries to parse the fields’ values to use them in mathematical operations. The |r modifier says the plugin you want to use the field’s raw value without preprocessing.

    So, the equation can be implemented as follows:

    (function(){
        var [a,b,c] = fieldname1|r.split(','),
            d = fieldname2,
            e = fieldname3;
        return (a-d)/(b-e)+c;
    })()

    But using the real fields’ names.

    Best regards.

    Thread Starter emilianomaina

    (@emilianomaina)

    Sorry but I am not able to make it working.

    Now in a test form I have:

    fieldname3 => Dropdown
    fieldname4 => Calculated Field

    In the calculated field, in the Set Equation of fieldname4 I wrote the following:

    (function(){
        var [a,b,c] = fieldname3|r.split",");
        return a+b+c;
    })()

    Nothing displayed.

    If I write simply fieldname3|r in Set Equation of fieldname4, the selected tuple is shown.

    I don’t know what is wrong.

    • This reply was modified 3 years, 3 months ago by emilianomaina.
    Plugin Author codepeople

    (@codepeople)

    Hello @emilianomaina

    You have a parser error in the equation, you have forgotten an open parenthesis. Please, use the equation:

    (function(){
        var [a,b,c] = fieldname3|r.split(",");
        return SUM(a,b,c);
    })()

    Best regards.

    Thread Starter emilianomaina

    (@emilianomaina)

    Now it works!

    Really thanks for your support.

    You opened a new world to me.

    Plugin Author codepeople

    (@codepeople)

    Hello @emilianomaina

    It has been a pleasure.

    Best regards.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Dropdown with Tuple’ is closed to new replies.