Dynamic Text and Answer Piping
Dynamic text inserts respondent answers, calculated values, and panel or row values into display strings. Use it when visible copy should reflect prior answers without calculating a new stored value.
Dynamic text is different from expression syntax:
- Use
{questionName}inside display text to pipe an answer into a title, description, choice label, HTML block, or completion message. - Use expression properties such as
visibleIf,requiredIf,setValueExpression,calculatedValues[].expression, and expression questionexpressionwhen SurveyJS needs to evaluate logic or compute a value. - Use stable
nameand choicevaluefields because dynamic text references those stored identifiers.
Common Targets
Section titled “Common Targets”Dynamic text can appear in localizable/display properties such as:
- Question, page, and panel
titleanddescription htmlquestion content- Choice
text,otherText,noneText, and similar labels - Text input
placeholder - Root
completedHtmlandcompletedHtmlOnCondition[].html - Dynamic panel
templateTitle,templateTabTitle, andtabTitlePlaceholder - Validator
text, required/min/max error text, and button labels
Basic Piping
Section titled “Basic Piping”{ "pages": [ { "name": "contact", "elements": [ { "type": "text", "name": "firstName", "title": "First name", "isRequired": true }, { "type": "html", "name": "personalIntro", "html": "<p>Thanks, {firstName}. The next questions are about your project.</p>", "visibleIf": "{firstName} notempty" }, { "type": "text", "name": "projectName", "title": "{firstName}'s project name" } ] } ], "completedHtml": "<h3>Thanks, {firstName}.</h3><p>We received your request for {projectName}.</p>"}Choice Labels
Section titled “Choice Labels”Use dynamic text in choice text when the stored value should remain stable but the visible label should include prior answers.
{ "type": "radiogroup", "name": "contactMethod", "title": "How should we contact {firstName}?", "choices": [ { "value": "email", "text": "Email {email}" }, { "value": "phone", "text": "Call {phone}" } ], "visibleIf": "{email} notempty or {phone} notempty"}Dynamic Panels
Section titled “Dynamic Panels”Inside dynamic panel templates, use panel-scoped placeholders when labels should refer to the current repeated item.
{ "type": "paneldynamic", "name": "dependents", "title": "Dependents", "displayMode": "tab", "templateTabTitle": "{panel.fullName}", "tabTitlePlaceholder": "Dependent", "templateElements": [ { "type": "text", "name": "fullName", "title": "Full name", "isRequired": true }, { "type": "text", "name": "birthDate", "title": "{panel.fullName}'s birth date", "inputType": "date" } ]}Generation Notes
Section titled “Generation Notes”- Prefer answer piping for visible copy and Expression Syntax for logic and calculations.
- Keep dynamic text short in titles and button labels. Use HTML for longer interpolated instructions.
- If a piped value may be empty, add
visibleIfor provide fallback copy so the rendered text still reads naturally. - Dynamic text can be combined with Localizable Strings by placing the same placeholder inside each translated string.
- Use Completion Behavior for post-submit messages that include answers or quiz score variables.