Have an idea?

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

Grid column based : dynamically hide a column depending on answer in previous column

Hi,

I have a column based grid : 10 rows ; 3 columns.

The columns labels are :
1. First choice
2. Second choice
3. Third choice

The rows labels are :
1. Websites
2. Magazines
3. Friends
...
10. No other choice

The respondant is asked to choose what she considers to be the most reliable source of information to shop for a swimming pool.  The row item #10 is there in case she feels like one or two sources of information are enough : the radio button display property of item #10 under the first column is set to none so she is forced to choose at least a first choice whereas the buttons for the same row item under the two other columns remain displayed.

The thing I would like to happen is this : If she clicks No other choice under column #2 (Second choice), then column #3 (Third choice) turns out to be no longer available either by disappearing in its whole div, either by making just the buttons (q1_c3_1_graphical, ..., q1_c3_10_graphical) disappear or becoming unclickable.

So far, I have tried quite a variety of scripts to achieve this without, of course, any success...

Among those trial and error (especially error here...) I had put a lot of hope and faith into the

<script type="text/javascript">
function SSI_CustomGraphicalRadiobox(GraphicalRadioboxObj, InputObj)
{
if(InputObj.name == "q1_c2_10")
{
document.getElementById(q1_c3_1_graphical).style.visibility="hidden";
document.getElementById(q1_c3_2_graphical).style.visibility="hidden";
document.getElementById(q1_c3_3_graphical).style.visibility="hidden";
.
.
.
document.getElementById(q1_c3_10_graphical).style.visibility="hidden";
}
}

</script>

as found in the SSI Web manual, but can't seem to get it working... Is there something I missed ?  I did put the script into the footer of the question without referencing with something like

<script type="text/javascript" src="/graphics/system/ssi_javascript8_3_10.js"></script>

.... would this had make a difference ?

Or maybe that the function SSI_CustomGraphicalRadiobox(GraphicalRadioboxObj, InputObj) is just not what is needed for the current purposes ?

VoilĂ . If a good hearted someone could help on this one, I would really appreciate !

Many thanx in advance,

Sebas
asked May 15, 2015 by sebas (235 points)
retagged May 15, 2015 by Walter Williams
Which version are you using.

1 Answer

0 votes
I am not exactly getting your question. But based on your above code, you have to modify code like below, it would work.

<script type="text/javascript">
function SSI_CustomGraphicalRadiobox(GraphicalRadioboxObj, InputObj)
{
    if(InputObj.name == "q1_c3")
    {
             
            if(InputObj.value==10)
            {
                var i = 1;
                for (i = 1; i < 10; i++) 
                {
                        document.getElementById("q1_c3_"+i+"_graphical").visibility = 'hidden';
                     document.getElementById("q1_c3_"+i+"_graphical").disabled = 'true';
                     document.getElementById("q1_c3_"+i+"_graphical").className = 'HideElement';
                 }
               }
    }
    if(InputObj.name == "q1_c2")
    {
             
            if(InputObj.value==10)
            {
                var i = 1;
                for (i = 1; i < 10; i++) 
                {
                        document.getElementById("q1_c2_"+i+"_graphical").visibility = 'hidden';
                     document.getElementById("q1_c2_"+i+"_graphical").disabled = 'true';
                     document.getElementById("q1_c2_"+i+"_graphical").className = 'HideElement';
                 }
               }
    }
}

</script>
answered May 15, 2015 by Rajesh Rana Gold (23,660 points)
...