OpenSpecimen supports the use of skip logic i.e. to shows/hide one or more fields based on the value of another field, in custom forms.
|
What are the different types of skip logic supported?
What is not supported currently?
Best practices to create skip logic in a form
Example form definition XML with skip logic: GeneticHistory.xml, Smoking History
Check the syntax of the "showWhen" tag in the above XML.
Sample form:
Form field | Control | Values | Control logic |
---|---|---|---|
Proband | Radio Button | Yes, No | - |
Relation with Proband | Drop down | Father, Mother, Son, Daughter, Others | The field should appear if option ‘No’ is selected for ‘Proband’ field |
Other Relation | String Text Box | - | The field should appear if option ‘Others’ is selected for ‘Relation with Proband’ field |
Try out the above sample form on demo site: 'Genetic History'
On selecting 'Yes', form field 'Relation with Proband' will not appear
On selecting 'No' option, form field 'Relation with Proband' will appear
Example of skip logic with condition involving logical operator:
Condition: Display 'FOBT Results' field when the value for 'FOBT Results' is either one of 'Positive' or 'Negative'
Syntax:
Example of skip logic to hide/show a subform
Condition: Display the subform "Family History Details" when the value of the field "Family Cancer History" is "Yes"
Syntax (to be added just above the subform control name): <showWhen><![CDATA[familyCancerHistory = "Yes" ]]></showWhen>
When 'Family Cancer History' value is 'No', subform does not appear.
When 'Family Cancer History' value is 'Yes', a subform 'Family History Details' is visible.