Expand my Community achievements bar.

Fields displayed conditional on the value of another field

Avatar

Former Community Member

I am a beginner and need help...

I have a form with 2 radio buttons (e.g. employee & contractor) - I want the user to enter data into 3 fields if employee is selected and a different set of 3 fields if contractor is selected.  I only want the 3 employee or the 3 contrcator fields to display at runtime.

1 Reply

Avatar

Level 10

Hi,

One way would be to wrap the fields for the employee in a subform "employeeSubform". You can then copy this subform using Edit / Copy Multiple. Set the number of copies to one and no vertical or horizontal movement. This will create an exact copy directly above the original.

Now set the presence of the employeeSubform to "hidden" on the Object / Field panel (just to get it out of the way for the time being). Edit the new subform by calling it contractorSubform and edit the fields.

Now select the radio buttons and go to the Object / Binding panel, set the "specify values" for employeeRB to "1" and the contactorRB to "2".

Now in the Click event of each radio button place the following Formcalc:

if (employeeRB <> 1 & contractorRB <>2 ) then  //checks if both radio buttons are not set

     employeeSubform.presence = "hidden"

     contractorSubform.presence = "hidden"

elseif (employeeRB == 1 ) then

     employeeSubform.presence = "visible"

     contractorSubform.presence = "hidden"

elseif (contractorRB == 2 ) then

     employeeSubform.presence = "hidden"

     contractorSubform.presence = "visible"

endif

This script will control the presence of the two subforms.  It might be worth wile considering who is going to fill in the form most often (employees or contractors) and then set the default value of the radio buttons to either 1 or 2.

Good luck,

Niall