Question T4230
Visible to All Users

Survey library: Hidden fields

created 5 years ago

Hello Team,

We want to have hidden fields in our form. Right now, if we select "is visible" to false, then the form element is not rendered at all.
I will give you some context why we want to do this. So, we want to render a card kind of thing in the form using html input. That card contains some data specific to user. Now, we setup form elements with data, hide them and use those as values while rendering html. Let me know your thoughts.

Thanks,
Navaneeth

Answers approved by surveyjs Support

created 5 years ago

Hello,
You can use calculated values. Here is the example.
Another option is to use variables.

Thank you,
Andrew
SurveyJS Team

    Show previous comments (7)

      What is wrong is survey.calculatedValues? You can store them in survey results if needed and put their any expression, including constant.

      Thank you,
      Andrew
      SurveyJS Team

        Hi, Andrew!

        What is wrong is survey.calculatedValues?

        I think problem in naming and documentation. Name calculated is not obvious for storing constant values. When I readed documentation I don't recognize that I can store constant in expression field.

        I just checked - it works for me, thank You again! But please, think about naming improvement. Possibly survey variables can be more clear for developers as variable can also store expression?

          Hello Boris,
          Yes, calculatedValues are not documented. We are going to fix this.
          Regarding variables. We have a variables concepts. You can use:
          survey.getVariable("yourValueName"); and survey.setVariable("yourValueName", value);. They are not bind with questions and they are not stored in survey.data. However, they can be used in expressions.

          Thank you,
          Andrew
          SurveyJS Team