Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Adapting question text on the fly depending on the value of a variable

I am curious about adapting text on the fly in questions (and CBC attribute levels) depending on the value of a variable which is determined as respondents complete the survey.

For example, depending on answers to some questions I assign a pass-in field (kids) the value of 1 or 2.

In various questions  I would like to have the text change  if kids=1.
For example,  question text that reads:

‘all symptoms and limitations of your children’s food allergies’

should become:
‘all symptoms and limitations of your child’s food allergies’.

The text that needs to be changed depending on the value of ‘kid’ varies, so I would like to be able to define this in each question or CBC attribute level as required (it is not a global replacement).

Is there a way to do this?

asked Mar 18 by dan r Bronze (2,810 points)

1 Answer

0 votes
Try using unverified Perl like this in the spots of your survey where you need dynamic text:

[% Begin Unverified Perl
my $kids = GETVALUE('kids');
if ($kids == 1) {
    return "all symptoms of child...";
if ($kids == 2) {
    return "all symptoms of children...";
End Unverified %]
answered Mar 18 by Zachary Platinum Sawtooth Software, Inc. (171,950 points)
Don't think the ink of my question even had time to dry....thank you!