Have an idea?

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

How to preselect using javascript

I have 5 select questions (Q1 to Q5) with Multiple answers in each. I want to find if code 4 or code  6 or code 7 were selected among Q1 to Q5,  we will auto select "Yellow" in Q6. If code 2 or code 3 were selected among Q1 to Q5,  we will auto select "Green" in Q6.

How can I do?
asked Jul 24, 2021 by Saroeun Bronze (2,995 points)

1 Answer

0 votes
This example should get you up and running ...

This script is for the "Yellow" code at Q6 (assuming it is item 1 in your list at Q6 - change "Q6_1" to what ever the yellow code is). Place this script in the footer of Q6.

I have assumed Q6 is also a multi-response type question.
if ("[%Q1_4%]"==1 || "[%Q1_6%]"==1 || "[%Q1_7%]"==1 || "[%Q2_4%]"==1 || "[%Q2_6%]"==1 || "[%Q2_7%]"==1 || "[%Q3_4%]"==1 || "[%Q3_6%]"==1 || "[%Q3_7%]"==1 || "[%Q4_4%]"==1 || "[%Q4_6%]"==1 || "[%Q4_7%]"==1 || "[%Q5_4%]"==1 || "[%Q5_6%]"==1 || "[%Q5_7%]"==1)
  SSI_SetSelect("Q6_1", true);

Apply the same approach to the "Green" code at Q6.
answered Jul 24, 2021 by Paul Moon Platinum (99,385 points)
Thanks Paul, another way how can I use count script.
If you are referring to a counter for the number of check box responses, go this forum post answered by Zachary Anderson ...