Question T1887
Visible to All Users

Problem with visibleIf and expession

created 6 years ago

Hello.
I found an issue with expression and visibleIf condition.

Example:
We have 2 number inputs and expression field which sums these two inputs, and 2nd input is visible only if 1st input is > 0.

User starts filling 1st input - 2nd input becomes visible.
User is filling 2nd input.
Then user sets "0" value to the 1st input - 2nd input becomes invisible.
Expression field shows the sum with hidden 2nd input.

Here is JSON:

Code
{ pages: [ { name: "page1", elements: [ { type: "text", name: "question1", inputType: "number" }, { type: "text", name: "question2", visibleIf: "{question1} > 0", inputType: "number" }, { type: "expression", name: "question3", expression: "{question1} + {question2}" } ] } ] }

I made a video for better understanding: https://monosnap.com/file/P0brAMv99RfGdlHAax2aVVKVtyFNie

Is it possible to set a value to default or null when field becomes invisible?

Answers approved by surveyjs Support

created 6 years ago

Hello Anton,
Please the survey.clearInvisibleValues = "onHidden"; to solve the issue.

Thank you,
Andrew
SurveyJS Team

    Comments (1)
    AB AB
    Anton Balandin 6 years ago

      Thanks!