Question T22526
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

Make other questions visible when a single question is visible

Making Question visible/hidden based on other question's visibility

created 4 days ago

Hi

I want to hide question1 if question2 is hidden and show question1 if question2 is visible.

Is there any option or logic to set in question2's property to implement this?

I know we can do this using javascript code, but I want to know if there is any available solution to use directly in form json.

Thanks
Shobhit

Answers approved by surveyjs Support

created 4 days ago

Hello Shobhit,
I suggest that you create a single calculated value which would manage visibility of multiple fields. Use this calculated field in the visibleIf expression for both question1 and question2. When the expression evaluates to true, both questions will be hidden.

If you necessarily need to make a question visible if another question is visible, you can register a custom function. Within this function, locate a target question using the SurveyModel.getQuestionByName(questionName) function and check whether the target question's visible property returns true. Use this custom function within another question's visibleIf expression.

I hope this information helps. Please let me know if you have any further questions.