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 by Saroeun Bronze (2,715 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.
<script>
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);
 }
</script>

Apply the same approach to the "Green" code at Q6.
answered Jul 24 by Paul Moon Platinum (94,725 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 ...

https://legacy.sawtoothsoftware.com/forum/21060/how-do-i-add-a-counter-to-a-multiple-select-question?show=21060#q21060
...