• Resolved cath_allen14

    (@cath_allen14)


    Hi,

    I have 8 different sets of radio buttons (fieldname1, fieldname2 etc). I would like to show a text field only if a radio button is selected within fieldname1, fieldname2, fieldname or fieldname 4.

    Is this possible?

    Thanks in advance
    Catherine

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

    (@codepeople)

    Hello @cath_allen14

    I’ll try to describe the process with a hypothetical example:

    Assuming there are four radio buttons fields in the form: fieldname1, fieldname2, fieldname3 and fieldname4, and an “Instruct. Text” field (the fieldname5), that you want to display only if the four radio buttons fields where selected by the user.

    Summarizing, you want to create a dependency but that depends on multiple fields at once, in this case the alternative would be a calculated field as auxiliary:

    1. Insert a calculated field in the form and enter as its equation the following one:

    
    IF(AND(fieldname1, fieldname2, fieldname3, fieldname4), 1, 0)
    

    2. In the settings of calculated field define the dependency: if value is equal to 1 then, and select the fieldname5 from the list of dependent fields.

    3. Finally, as the calculated field is not essential in the form’s interface, you can hide it, ticking the checkbox: “Hide this field from the public form” in its settings.

    and that’s all.
    Best regards.

    Thread Starter cath_allen14

    (@cath_allen14)

    Thanks for the quick reply!

    I can’t seem to get this to work. Within each fieldname there are 4 or 5 radio buttons, e.g. fieldname1 has 4 radio buttons, fieldname2 has 5 radio buttons etc – if a radio button is selected in either of these fields then I would like to display the text field.

    Thanks in advance!
    Catherine

    Plugin Author codepeople

    (@codepeople)

    Hello @cath_allen14

    In this case you simply should to replace the AND operation by OR. Following the same example:

    
    IF(OR(fieldname1, fieldname2, fieldname3, fieldname4), 1, 0)
    

    Best regards.

    Thread Starter cath_allen14

    (@cath_allen14)

    Hmm, I still can’t get this to work. Here is a link to my page:
    https://ocnprt.com/q-stoneworks/instant-quote/

    If a customer clicks on a sample image (they’re hidden radio buttons) in Granite Price Band 1 (fieldname8), Granite Price Band 2 (fieldname11), Granite Price Band 3 (fieldname14) or Granite Price Band 4(fieldname20) then a hidden div area (fieldname386) should display under the “4. Select Your Additional Features” section.

    Here is my function:
    (function(){
    IF(OR(fieldname8, fieldname11, fieldname14, fieldname20), 1, 0)
    })()

    I’m not sure what I’m doing wrong!

    Thanks in advance

    Plugin Author codepeople

    (@codepeople)

    Hello @cath_allen14

    You should take the decision, or use the IF operation directly:

    
    IF(OR(fieldname8, fieldname11, fieldname14, fieldname20), 1, 0)
    

    or if you want to define the equation with a function structure, you should use the javascript instruction: “return”

    
    (function(){
    return IF(OR(fieldname8, fieldname11, fieldname14, fieldname20), 1, 0);
    })()
    

    Best regards.

    Thread Starter cath_allen14

    (@cath_allen14)

    Perfect thanks – that works!

    However, if I click on a Granite radio button (fieldname8, 11, 14 or 20) and then change my mind and click on the Quartz radio button (fieldname26) the value doesn’t reset itself to 0 and therefore the div fieldname386 doesn’t disappear.

    Can this be done so the value updates if the user changes their chosen material?

    Thanks in advance!

    Plugin Author codepeople

    (@codepeople)

    Hello,

    I don’t know what do you want to implement exactly. Your current equation is (this was your request):

    
    IF(OR(fieldname8, fieldname11, fieldname14, fieldname20), 1, 0)
    

    So, if any of fields: fieldname8, fieldname11, fieldname14 or fieldname20 has a value (that means an option is selected) the equation will returns 1 and in this case the dependency rule would be true and the fieldname386 would be visible.

    If you want the equation returns 1 only if no Quartz has been selected, evidently you should combine the OR operator with an AND where the value of the Quartz field be equal to zero.

    I’m sorry, but the support service does not cover the implementation of the users’ projects (forms or formulas).

    Thread Starter cath_allen14

    (@cath_allen14)

    Hi,

    Sorry I don’t think I was clear in my previous reply.

    If a user clicks on fieldname8, fieldname11, fieldname14 or fieldname20 then fieldname386 becomes visible.

    If they click on fieldname8, fieldname11, fieldname14 or fieldname20 and then they change their mind and click on fieldname26 then the fieldname386 is still visible but I assumed fieldname386 should hide again in this scenario as the equation doesn’t include fieldname26.

    Thanks in advance
    Catherine

    Plugin Author codepeople

    (@codepeople)

    Hello @cath_allen14

    Yes, I understod you the first time, and answered your question in my previous ticket:

    …If you want the equation returns 1 only if non Quartz has been selected, evidently you should to combine the “OR” operator in the equation with an “AND”, where the value of the Quartz field should be equal to zero…

    Best regards.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Display field based on radio button selection’ is closed to new replies.