Have an idea?

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

Pre Select based on responses to previous questions?

I would like to use the SSI_SetSelect function, but need to pre select responses based on answers to previous questions.
For example,
If Q1 = 1 then I would like to pre select "1" in Q2.
Any help is greatly appreciated.
Thanks,
Christine
asked Mar 19, 2014 by ChristineCarll (370 points)

2 Answers

0 votes
You can add add this Perl script into you survey to set Q2=1 if Q1=1...

[% Begin Unverified Perl

 if (VALUE("Q1")==1)
 {
  SETVALUE("Q2",1);
 }
 
End Unverified %]


*Note - I have assumed Q1 and Q2 are single response. Change their syntax if they are another question type (e.g. Q2_1, Q2_r1, etc.).

You may skip Q2 if Q1=1 and then add this script to the footer of a question after Q2. That should work.
answered Mar 19, 2014 by Paul Moon Platinum (91,280 points)
edited Mar 20, 2014 by Paul Moon
Brilliant!
However... I think SETVALUE is not available in version 7. Is that true?
SetValue and GetValue are v8 features.
0 votes
In v7, I would recommend to use jquery for same purpose. Let' say i have Q1 as single select question and Q2 another one single select question. I will use below code to show autoselect based on Q1 at Q2.

<script language='javascript' type='text/javascript'>
    jQuery.noConflict();
    jQuery(document).ready(function ($) 
    {
        
                $("#Q2_[%Q1%]_graphical").removeClass("radiobox");
                $("#Q2_[%Q1%]_graphical").addClass("radioboxselected");
                $("#Q2_[%Q1%]").attr("checked", "checked");    
        
        });
</script>


Let me know for more help
answered Mar 21, 2014 by Rajesh Rana Gold (24,865 points)
edited Mar 21, 2014 by Rajesh Rana
...