Accessibility Compliance
SurveyJS libraries meet a variety of WCAG and Section 508 standards. Run AXE® Validation to assess this demo’s accessibility level.

Preview Surveys with Runtime Variables

Edit in →

Survey logic can depend on application data, such as a customer's plan or role. To test this logic, you can save sample values as named sets called variable presets. Use the selector at the bottom of Preview to switch between three customer profiles: "Basic member", "Premium member", and "Premium administrator". Click Manage presets to view, edit, add, or delete presets.

To configure presets, set the variablePresets property to an object with these properties:

  • definition
    A survey JSON definition whose questions describe the variables. Question names identify variables, while question types, choices, and validators configure the preset editor. In this demo, a Dropdown question defines customerTier and a Yes/No question defines isAccountAdmin.
  • presets
    An array of named variable presets. Each entry contains a unique name, an optional description, and a variables object that maps variable names to values.

Variables in survey expressions are referenced using curly brackets, just as question names. This demo uses "enableIf": "{customerTier} = 'premium'" to enable priority support and "visibleIf": "{isAccountAdmin} = true" to show the billing question. The variable definition also makes these variables available in visual condition editors.

Preset edits are kept in memory for the browser session. To save them, handle the onVariablePresetsChanged event and persist options.variablePresets when options.reason === "edit".

Refer to the Code tab for the complete survey and variable preset definitions.

Your cookie settings

We use cookies to make your browsing experience more convenient and personal. Some cookies are essential, while others help us analyse traffic. Your personal data and cookies may be used for ad personalization. By clicking “Accept All”, you consent to the use of all cookies as described in our Terms of Use and Privacy Statement. You can manage your preferences in “Cookie settings.”

Your renewal subscription expires soon.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.

Your renewal subscription has expired.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.