• Resolved ateliernatuerlich

    (@ateliernatuerlich)


    Hello,

    I have been trying for hours to figure this out by myself, but I am at a loss. Could you please help me?

    I have read the article “Q: How to select a choice in a DropDown field, or Radio Button, based on calculated value?” but I don’t really understand WHERE I have to add the code with the value/choice selected…
    The article is not very clear for people who are not familiar with your form and the equations…

    This is what I am trying to do:

    Number = the amount the user wants to convert

    Selections field 1 = 3 options (the user has to select the unit in which the above entered amount is in)

    Selection field 2 = 3 options (the unit the user wishes to convert the amount into)

    Basically:
    1,0 Festmeter (Fm) = 1,6 Raummeter (Rm) = 2,4 Schüttraummeter (Srm)
    1,0 Raummeter (Rm) = 0,6 Festmeter (Fm) = 1,5 Schüttraummeter (Srm)
    1,0 Schüttraummeter (Srm) = 0,4 Festmeter (Fm) = 0,7 Raummeter (Rm)

    So for example I enter 2 Raummeters and want it converted into Festmeter I should get 1.2 Festmeter.

    I added a Numbers field and two radio button fields… but I don’t know where to add the values, since they depend on the selection of the OTHER selection field…

    Thank you for your help,

    Maria

    https://wordpress.org/plugins/calculated-fields-form/

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

    (@codepeople)

    Hi,

    I don’t understand exactly the behavior you want to emulate.

    Could you send me the link to your webpage to check the form’s structure, and the fields values, please?

    Best regards.

    Thread Starter ateliernatuerlich

    (@ateliernatuerlich)

    Hello,

    I changed it into mm, cm and meters to make it easier to understand. (the values are not correct since I don’t know where to put them – they depend on the selection of the first unit).

    I want a converter where the user can enter an amount in for example mm and convert it into cm.

    Here is the page:
    http://holz-rauch.de/converter/

    I don’t know how I can select a choice in the equation. I can only select the fiel – which is the entire selection. I need to know the unit in which the original amount is in in order to convert it into another unit.

    Thank you for all your help!
    Maria

    Plugin Author codepeople

    (@codepeople)

    Hi,

    You simply should use conditional statements in your equation for checking the options selected in each field. Your current form includes the fields:

    Amount: fieldname4
    Current Unit: fieldname7
    Convert into: fieldname8
    and the Result field: fieldname9

    I will convert the source value to mm in function to the option selected in the fieldname7, and then, convert it to the magnitude selected in the fieldname8:

    (function(){
    
    var r = fieldname4;
    
    switch(fieldname7)
    {
    case 'mm': r = r; break;
    case 'cm': r = r*10; break;
    case 'm':  r = r*1000; break;
    }
    
    switch(fieldname8)
    {
    case 'mm': r = r; break;
    case 'cm': r = r/10; break;
    case 'm':  r = r/1000; break;
    }
    
    return r;
    })()

    Please, for additional questions related with custom equations, creates a ticket in our private support page, and requests a custom coding service.

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Multiple selection choices’ is closed to new replies.