• Resolved victoriei101

    (@victoriei101)


    Hello, newbie here, I was wondering how can I create a form with 4 calculated fields that calculate based on a radio button field with 4 options.

    On radio button field:
    -when option A is selected fieldname4=fieldname2*.25
    -when option B is selected fieldname4=(fieldname2*.3333)/2 and fieldname5=(fieldname2*.3333)/2
    -when option C is selected fieldname4=(fieldname2*.5)/3 and fieldname5=(fieldname2*.5)/3 and fieldname6=(fieldname2*.5)/3
    -when option D is selected fieldname4=(fieldname2*.5)/4 and fieldname5=(fieldname2*.5)/4 and fieldname6=(fieldname2*.5)/4 and fieldname7=(fieldname2*.5)/4

    I made a layout of what I mean
    https://ibb.co/album/wZQ8zv

    input value is fieldname2
    radio button is fieldname3
    calculated fields are:
    1 is fieldname4
    2 is fieldname5
    3 is fieldname6
    4 is fieldname7

    Can you please help me with this? Thank you

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

    (@codepeople)

    Hello @victoriei101

    I’ll assume the values of the radio button’s choices are: A, B, C, D

    The equations associated with the calculated fields could be:

    For the fieldname4:

    
    (function(){
        switch(fieldname3)
        {
            case 'A': return fieldname2*0.25;
            case 'B': return (fieldname2*0.3333)/2;
            case 'C': return (fieldname2*0.5)/3;
            case 'D': return (fieldname2*0.5)/4;
        }
    })()
    

    For the fieldname5:

    
    (function(){
        switch(fieldname3)
        {
            case 'B': return (fieldname2*0.3333)/2;
            case 'C': return (fieldname2*0.5)/3;
            case 'D': return (fieldname2*0.5)/4;
        }
    })()
    

    For the fieldname6:

    
    (function(){
        switch(fieldname3)
        {
            case 'C': return (fieldname2*0.5)/3;
            case 'D': return (fieldname2*0.5)/4;
        }
    })()
    

    For the fieldname7:

    
    (function(){
        if(fieldname3 == 'D') return (fieldname2*0.5)/4;
    })()
    

    The previous equations are only one of the multiple possibilities of their implementation.

    Best regards.

    Thread Starter victoriei101

    (@victoriei101)

    Thank you.
    Have a nice day.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Radio buttons different calculations’ is closed to new replies.