This is a follow up to a question I asked a couple days ago...
https://www.sawtoothsoftware.com/forum/1178/hide-a-checkbox-in-a-grid-question
Suppose I have this grid question - column based with checkboxes. (The "O"'s in my example are graphical checkboxes)
Q1
A B
Row 1 O O
Row 2 O O
Row 3 O O
Now I have another gird question with the same format but I only want to display the checkboxes that were checked in the previous question. In other words, if a respondent answers like this...
Q1
A B
Row 1 X O
Row 2 X O
Row 3 O X
I want the next question to display this...
Q2
A B
Row 1 O
Row 2 O
Row 3 O
I can hide a checkbox in Q2 with the following code:
<script>
document.getElementById("Q2_r1_c1_graphical").visibility = 'hidden';
document.getElementById("Q2_r1_c1_graphical").disabled = 'true';
document.getElementById("Q2_r1_c1_graphical").className = 'HideElement';
</script>
But I can't figure out how to format the "if" part around it to base it on Q1. Something like this...
<script>
if([%Q1_r1_c1%] <> 1)
{
document.getElementById("Q2_r1_c1_graphical").visibility = 'hidden';
document.getElementById("Q2_r1_c1_graphical").disabled = 'true';
document.getElementById("Q2_r1_c1_graphical").className = 'HideElement';
}
if([%Q1_r1_c2%] <> 1)
{
document.getElementById("Q2_r1_c2_graphical").visibility = 'hidden';
document.getElementById("Q2_r1_c2_graphical").disabled = 'true';
document.getElementById("Q2_r1_c2_graphical").className = 'HideElement';
}
//etc.
...except that doesn't work. The checkbox always displays no matter how I answer Q1. I've tried it a hundred different ways but can't seems to get the syntax right - or maybe I'm missing something else.