Have an idea?

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

Display the "other" response to a previous question in combination with skip logic

At the beginning of my survey I ask participants (scientists) in which scientific field they work. Depending on their response, I then ask them to indicate the subfield (using skip logics). Both questions have radio buttons (single response) and a "other specify" option so that they are required to enter text if they choose "other".

Later in the survey, I would like to include the response to the second question "scientific subfield" (for which there are six different versions, for each scientific field) into a sentence. I have used unverified perl to do this and it works fine for the radio buttons responses (using if functions). But now I would like to add that, if a participant chooses the "other" option and enters text, this text appears in the sentence instead. If the participant chooses "other" for the first question, this response should be included in the sentence (the second question on the subfield is skipped, so it would only make sense to include this response).

However, I can't figure out how to include the responses to "other specify". Neither for the first question, nor the second one. The text simply doesn't show up. But there is also no error message.

Here's what I've tried:

[% Begin Unverified Perl
if(GETVALUE("ScientificField") == 1)
if(GETVALUE("ScientificField") == 2)
if(GETVALUE("ScientificField") == 3)
if(GETVALUE("ScientificField") == 4)
if(GETVALUE("ScientificField") == 5)
if(GETVALUE("ScientificField") == 6)
if(GETVALUE("ScientificField") == 7)
End Unverified %]

ScientificField is the first question; ScientificField1 the first version of the second question and so on...

ScientificField has seven response options, with 7 as the "other specify" option.

Thank you very much in advance for any advice you could give me for solving this problem!
asked Apr 7, 2017 by Laura

1 Answer

0 votes
You need to use returns to get unverified Perl to print out a value:

if (GETVALUE("ScientificField") == 1) {
    return LABEL('ScientificField1');

If you want to print out the response to an other specify, you should use GETVALUE instead of LABEL:

return GETVALUE('ScientificField_7_other');
answered Apr 7, 2017 by Zachary Platinum Sawtooth Software, Inc. (100,575 points)
Thanks! Now it works exactly the way it should.