Have an idea?

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

Autofill with a previous numeric value and skip question if only one item is selected

Simple example:

Q1 How many pens do you have?
Answer Q1=10

Q2 What colours are your pens?
Multiple Choices:

Q3 Of your [%Value(Q1)%] pens, how many pens of each colour do you have?
Blue ___
Red _____
Black ____

If only one colour was selected in Q2, let's say "blue" then all my pens are blue, hence Q3 could be skipped but I still need to record a value under Q3_blue equal to the Q1 value.

I know how to skip Q3 using ListLength(Q2)=1 but I don’t know how to autofill Q3 based on the answers to Q1 and Q2.

I would like someone to help me translating the following into a script that Sawtooth will understand:

If ListLength(Q2)= 1
 For i=1 to 3 (my 3 colours in Q2)
      if (Q2_i=1) then Q3_ri_c1=Q1

Any suggestions? Thanks in advance.
asked May 23, 2012 by anonymous
retagged Sep 13, 2012 by Walter Williams

1 Answer

0 votes

as far as I know you can't set a questions value in SSIWeb up to and including v7, EXCEPT
1- insert a free-format question on the next page of your Q3 and change its value to either Q3 (if not skipped) or whatever is selected in Q1 (if Q3 skipped)
2- insert a javascript on Q3 to set the value on page load and auto submit, but depending on internet connection and computer processor, you might see the page for a short time
answered May 23, 2012 by Bahadir Ozkurt Gold (16,980 points)
Thank you Bahadir for your prompt answer. Option 1 could work if there was only 1 item in Q2, otherwise, where I have 10 items I'd have to set up 10 free-format questions to store the value for each brand and that cannot work for my study since I have to do this waaay to many times.

I could try your option 2 if you could only tell me how this works. How to I "set the value" and then "auto submit"? Can I customize the setting of the value for sevel items as mentioned, meaning if brand 2 was selected in Q2 then set the value of row 2 in Q3 as Q1....and so on.

its actually one freeformat question with 10 variables :) i dont know if this makes it easier to implement for you...

as for the second one; youll need to write the pseudo-code you've written above in javascript. probably with "eval" you could make it work
lol...could you help me with the javascipt... I don't know javascript that's why I have the pseude-code. To make it simpler, ignore the loop, what is the script that will do the following:
if Q2_1=1 then Q3_1=Q1? Thanks!
ah sorry, it will take some time to pin it right and I'm busy with my own stuff... perhaps searching for javascript on this forum might give some usable code
no worries. I just thought my original question had an easy answer that I cannot figure out. I'm new at using sawtooth and I'm still learning how to use unverified perl and javascript for my needs. I have a few weeks to figure it out :) Thanks though :)
Hi. I believe the following will work for you.... (I have seen this happen in my own surveys)

1) Set up Q3 as a constant sum question and set the "Constant Sum Setting" (under "Settings" tab) as [%Value(Q1)%]
2) Construct your list for Q3 to only include those members selected in Q2

That's it... If Q2 only has one member, Q3 will be skipped and the value of [%Value(Q1)%] will be inserted as the answer for the single code from Q2.

That works perfectly!!!
I never used constant sum before and I didn't know what it does but I like it so I'll read more about it; I'm still new with sawtooth!

Thank you so much Russell!!! Best simple answer!