Have an idea?

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

Auto Fill in numeric response

Hi,

I have 3 questions, first one is a multiselect question

Q1. Which of the following devices do you own?
Apple
Samsung
HTC
LG
Sony
Huawei
Lenova

second one is a numeric question

Q2. How many total hours per week do you play video games?

third one is also a numeric

Q3. You said that you play [PIPE IN RESPONSE FROM Q2] hours of video games each week.
[ROWS – CONSTRUCT LIST BASED ON ITEMS CHOSEN IN Q1]
Apple
Samsung
HTC
LG
Sony
Huawei
Lenova

If only one option is selected in Q1 then response of Q2 to be auto filled in Q3 rather than showing that only one option in Q3. For e.g. if only 'Samsung' selected in Q1 then Q2 response to be assigned to 'Samsung' of Q3.

Please let me know how to acheive this.
asked May 13, 2015 by Abdul Bronze (2,630 points)

1 Answer

+1 vote
 
Best answer
I am assuming you have Q3 on a separate page from Q1 and Q2.

You can skip Q3 if Q1 is only answered once. Use the SSI Script function NumChecked(Q1)=1 at Q3 to handle the display of Q3,

You can then use the SetValue function and some Perl script to set the correct Q3 item to the value of Q2 if Q1 is only answered once.

Insert this Perl script at the footer of a question after Q3 ...
[%Begin Unverified Perl
  
my $i=1;
my $x=0;

if (NUMCHECKED("Q1")==1)
 {
  for($i=1; $i<=7; $i++)
   {
    if (VALUE("Q1_".$i)==1)
    {  
     $x=$i;
    }  
   }

  SETVALUE("Q3_r".$x."_c1",VALUE("Q2"));
 }
  
End Unverified%]

Run some test surveys and check your data via the admin module. I got it working just fine.

Note 1 - you may consider making Q3 a constant sum question if you want all items at Q3 to add to the Q2 value. You can insert [%Q2%] as the total value.

Note 2 - if you had Q1 and Q2 and Q3 all on the same page, you would have to implement some fancy JavaScript to control the Q3 grid items and the Q3 data insertion.
answered May 13, 2015 by Paul Moon Platinum (82,075 points)
selected May 13, 2015 by Abdul
Thanks Paul. It works great.
...