Hi everyone,
I'm working on a survey on Sawtooth SSI Web 8.4.8
I'm asking a series of 15 questions about different traumatic events people have experienced. If they have never experienced a traumatic event I want to skip them directly ahead of this section to another section. The 15 questions are binary numeric variables, with 0 for no and 1 for yes. If the person has experienced one traumatic event I want to skip them ahead to question 1. If they have experienced more than one traumatic event I want to skip them ahead to question 2.
I know how to do this using the built in skipping feature, however for this survey for various reasons I don't want to use it, so I'm trying to achieve the skips using javascript (although if anybody knows a way to do it in Unverified Perl that would be helpful too).
Because there are 15 prior questions and the answers to each of them must be taken into consideration, I was going to try to figure out a way to combine them into an assay and sum the value, so if the total sum of the 15 questions is 0 it will go to the next section, if it is 1 it will go to question 1, and if it is 2 or more it will go to question 2.
I am having trouble figuring out the coding for this however, this is what I'm starting with
setInterval(function () {
if( SSI_GetValue("trauma") == 1 ) {
$("#[% QuestionName() %]_div").css('display', 'block');
}
else {
$("#[% QuestionName() %]_div").css('display', 'none')
}}, 100);
</script>
and I thought maybe I could use an assay like this
var trauma = ["tram1", "tram2", "tram3", "tram4", "tram5", "tram6", "tram7", "tram8", "tram9", "tram10", "tram11", "tram12", "tram13","tram14", "tram15"]
but I need to figure out a way to work it inside the previous coding.
If anybody could help me figure out the coding or give me an alternate method of solving the problem using javacript or Perl that would be great.
Thanks in advance!