Have an idea?

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

Grid question auto punch

I have 2 questions one is multi select (Q2A) and other one is single select (Q3A). If only one option is selected in Q2A then I need to auto code that one option in Q3A and skip. Tried below code in Q3A and in next question of Q3A in custom JavaScript but it is not working


if([%Q2A_r1_c1%]==1 && [%Q2A_r2_c1%]==0  && [%Q2A_r3_c1%]==0 && [%Q2A_r4_c1%]==0 && [%Q2A_r5_c1%]==0)
{
    Q3A_c1=1;
}
if([%Q2A_r1_c1%]==0 && [%Q2A_r2_c1%]==1  && [%Q2A_r3_c1%]==0 && [%Q2A_r4_c1%]==0 && [%Q2A_r5_c1%]==0)
{
    Q3A_c1=2;
}
if([%Q2A_r1_c1%]==0 && [%Q2A_r2_c1%]==0  && [%Q2A_r3_c1%]==1 && [%Q2A_r4_c1%]==0 && [%Q2A_r5_c1%]==0)
{
    Q3A_c1=3;
}


I do not need of AIC function as it a grid question. Please help.
asked Nov 21, 2013 by Abdul Bronze (2,630 points)

1 Answer

+3 votes
Here  is the solution

<script type="text/javascript">

if([%Q2A_r1_c1%]==1 && [%Q2A_r2_c1%]==0  && [%Q2A_r3_c1%]==0 && [%Q2A_r4_c1%]==0 && [%Q2A_r5_c1%]==0)
{
    SSI_SetSelect("Q3A_c1_1", true); 
setTimeout('SSI_SubmitMe()',10); 
}
if([%Q2A_r1_c1%]==0 && [%Q2A_r2_c1%]==1  && [%Q2A_r3_c1%]==0 && [%Q2A_r4_c1%]==0 && [%Q2A_r5_c1%]==0)
{
     SSI_SetSelect("Q3A_c1_2", true);
setTimeout('SSI_SubmitMe()',10);
}
if([%Q2A_r1_c1%]==0 && [%Q2A_r2_c1%]==0  && [%Q2A_r3_c1%]==1 && [%Q2A_r4_c1%]==0 && [%Q2A_r5_c1%]==0)
{
     SSI_SetSelect("Q3A_c1_3", true);
setTimeout('SSI_SubmitMe()',10);
}

 </script>
answered Nov 21, 2013 by Rajesh Rana Gold (24,770 points)
Hi ranarajesh, It is not working. I have tried this code in Q3A and in the next question of Q3A (both in footer and custom JavaScript).
Which version you are using?
Actually I just checked on both version and it is working. can you tell me in more details way what you are getting on Q3A? Are you getting auto-select response but not auto-submit page or what else?
This is just a continuation of the below one we discussed, if 2 or more options selected in Q2A then I need to show Q3A with hidden option. If only one option is selected in Q2A then I need to auto code that one option in Q3A and skip as it is not a logic to show only one option in Q3A.

https://www.sawtoothsoftware.com/forum/4881/hide-radio-button
So you have two column, But if only one column has one element selected. You want it autoselect and hide and ask only for second option. Am i Correct.
Yes, exactly.
Can you check with this.

<script type="text/javascript">
if([%Q2A_r1_c1%]==1 && [%Q2A_r2_c1%]==0  && [%Q2A_r3_c1%]==0 && [%Q2A_r4_c1%]==0 && [%Q2A_r5_c1%]==0)
{
    SSI_SetSelect("Q3A_c1_1", true);
document.getElementById("Q3A_c1_1_graphical").visibility = 'hidden';
document.getElementById("Q3A_c1_1_graphical").disabled = 'true';
document.getElementById("Q3A_c1_1_graphical").className = 'HideElement';
document.getElementById("Q3A_c1_2_graphical").visibility = 'hidden';
 document.getElementById("Q3A_c1_2_graphical").disabled = 'true';
 document.getElementById("Q3A_c1_2_graphical").className = 'HideElement';
document.getElementById("Q3A_c1_3_graphical").visibility = 'hidden';
 document.getElementById("Q3A_c1_3_graphical").disabled = 'true';
 document.getElementById("Q3A_c1_3_graphical").className = 'HideElement';
 document.getElementById("Q3A_c1_4_graphical").visibility = 'hidden';
 document.getElementById("Q3A_c1_4_graphical").disabled = 'true';
 document.getElementById("Q3A_c1_4_graphical").className = 'HideElement';
 document.getElementById("Q3A_c1_5_graphical").visibility = 'hidden';
 document.getElementById("Q3A_c1_5_graphical").disabled = 'true';
 document.getElementById("Q3A_c1_5_graphical").className = 'HideElement';
}
if([%Q2A_r1_c1%]==0 && [%Q2A_r2_c1%]==1  && [%Q2A_r3_c1%]==0 && [%Q2A_r4_c1%]==0 && [%Q2A_r5_c1%]==0)
{
    SSI_SetSelect("Q3A_c1_2", true);
document.getElementById("Q3A_c1_1_graphical").visibility = 'hidden';
document.getElementById("Q3A_c1_1_graphical").disabled = 'true';
document.getElementById("Q3A_c1_1_graphical").className = 'HideElement';
document.getElementById("Q3A_c1_2_graphical").visibility = 'hidden';
 document.getElementById("Q3A_c1_2_graphical").disabled = 'true';
 document.getElementById("Q3A_c1_2_graphical").className = 'HideElement';
document.getElementById("Q3A_c1_3_graphical").visibility = 'hidden';
 document.getElementById("Q3A_c1_3_graphical").disabled = 'true';
 document.getElementById("Q3A_c1_3_graphical").className = 'HideElement';
 document.getElementById("Q3A_c1_4_graphical").visibility = 'hidden';
 document.getElementById("Q3A_c1_4_graphical").disabled = 'true';
 document.getElementById("Q3A_c1_4_graphical").className = 'HideElement';
 document.getElementById("Q3A_c1_5_graphical").visibility = 'hidden';
 document.getElementById("Q3A_c1_5_graphical").disabled = 'true';
 document.getElementById("Q3A_c1_5_graphical").className = 'HideElement';
}
if([%Q2A_r1_c1%]==0 && [%Q2A_r2_c1%]==0  && [%Q2A_r3_c1%]==1 && [%Q2A_r4_c1%]==0 && [%Q2A_r5_c1%]==0)
{
    SSI_SetSelect("Q3A_c1_3", true);
document.getElementById("Q3A_c1_1_graphical").visibility = 'hidden';
document.getElementById("Q3A_c1_1_graphical").disabled = 'true';
document.getElementById("Q3A_c1_1_graphical").className = 'HideElement';
document.getElementById("Q3A_c1_2_graphical").visibility = 'hidden';
 document.getElementById("Q3A_c1_2_graphical").disabled = 'true';
 document.getElementById("Q3A_c1_2_graphical").className = 'HideElement';
document.getElementById("Q3A_c1_3_graphical").visibility = 'hidden';
 document.getElementById("Q3A_c1_3_graphical").disabled = 'true';
 document.getElementById("Q3A_c1_3_graphical").className = 'HideElement';
 document.getElementById("Q3A_c1_4_graphical").visibility = 'hidden';
 document.getElementById("Q3A_c1_4_graphical").disabled = 'true';
 document.getElementById("Q3A_c1_4_graphical").className = 'HideElement';
 document.getElementById("Q3A_c1_5_graphical").visibility = 'hidden';
 document.getElementById("Q3A_c1_5_graphical").disabled = 'true';
 document.getElementById("Q3A_c1_5_graphical").className = 'HideElement';
}
</script>
<script type="text/javascript" src="/graphics/system/jquery-ui-1.8.17.min.js"></script>
<script type="text/javascript">
    jQuery.noConflict();
    jQuery(document).ready(function ($) {
    if((([%Q2A_r1_c1%]==1 && [%Q2A_r2_c1%]==0  && [%Q2A_r3_c1%]==0 && [%Q2A_r4_c1%]==0 && [%Q2A_r5_c1%]==0)) || (([%Q2A_r1_c1%]==0 && [%Q2A_r2_c1%]==1  && [%Q2A_r3_c1%]==0 && [%Q2A_r4_c1%]==0 && [%Q2A_r5_c1%]==0)) || (([%Q2A_r1_c1%]==0 && [%Q2A_r2_c1%]==0  && [%Q2A_r3_c1%]==1 && [%Q2A_r4_c1%]==0 && [%Q2A_r5_c1%]==0)))
{
$("#Q3A_c1_1_graphical").parent("td").removeClass("clickable");
$("#Q3A_c1_2_graphical").parent("td").removeClass("clickable");
$("#Q3A_c1_3_graphical").parent("td").removeClass("clickable");
$("#Q3A_c1_4_graphical").parent("td").removeClass("clickable");
$("#Q3A_c1_5_graphical").parent("td").removeClass("clickable");
}
});
</script>

You need to modified code based upon 5 rows. It will hide the option and autopunching for that row. But best solution is, using constructed list with perl code. and don't show that column. And auto-punch in data. I can work for you if you want that one too.
...