• Resolved martymcleod

    (@martymcleod)


    Hi! I am able to implement my forms, but it seems very inefficient currently. I am using the Dropdown for the user to select a variety of values/choices to be calculated.

    Currently, I have to use switch{}/case: clauses for the choice text switch(fieldname7|r) in each field. For example:

    /* Calculate using the fields that appear via the user
       dropdown selection */
    (function(){
    var result;
    switch(fieldname7|r)
    {
    case 'option1': result = 0.03003/fieldname14;
    break;
    case 'option2': result = 0.03003/fieldname36;
    break;
    case 'option3': result = 0.03003/fieldname39;
    break;
    }
    return PREC(result*1000000,1);
    })()

    rather than simply:

    1. Assigning values to variables based on the user dropdown choice.
    2. Calculate in desired fields using those variables (as opposed to having to use switch(), case: based on the choice text/specific fields selected via the dropdown.

    i.e.,:

    (function(){
    var result;
    /* Calculate using the variables assigned values
       by the dropdown user selection */
    
       result = variable1/(pow(variable2,2)*variable3);
    
       return PREC(result*1000000,1);
    })()

    Is that possible? Can the dropdown also be associated with a function or code snippet to assign values to variables, etc?

    Thank you! ??

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

    (@codepeople)

    Hello @martymcleod,

    The simpler solution would be to insert a calculated field in the form to get the value based on the DropDown field (Ex. fieldname123):

    (function(){
    var result;
    switch(fieldname7|r)
    {
    case 'option1': result = 0.03003/fieldname14;
    break;
    case 'option2': result = 0.03003/fieldname36;
    break;
    case 'option3': result = 0.03003/fieldname39;
    break;
    }
    return PREC(result*1000000,1);
    })()

    And then use it from other equations.

    Another alternative would be to generate the variables from an equation and evaluate the other calculated fields’ equations explicitly.

    For example:

    (function(){
    variable1 = fieldname1+fieldname2;
    variable2 = fieldname1*fieldname2;
    EVALEQUATION(fieldname3|n);
    EVALEQUATION(fieldname4|n);
    EVALEQUATION(fieldname5|n);
    })()

    In this hypothetical use case, fieldname3, fieldname4, and fieldname5 are calculated fields whose equations use the variables.

    Best regards.

    Thread Starter martymcleod

    (@martymcleod)

    Not sure why but I had not thought about the 1st idea. Thank you! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Question Regarding Passing Values To Fields’ is closed to new replies.