Have an idea?

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

JavaScript code in a Grid question

I have a grid question requiring some JavaScript code. Can anyone help please?

Let's assume I have 20 brands with code 21 being "None of the above".

Column 1 (Q1a) - multiple response type answers (ANY USE - check boxes).

Column 2 (Q1b) - single response type answers (MOST USE - radio buttons.

Problem 1 - If I say "None of the above" in column 1, automatically select the "None of the above" radio button in column 2.

Problem 2 - If I select any of brands 1-20 in column 2, automatically select that same brand in column 1 if it has not already been selected.

Thanks.
asked Jun 10, 2013 by Paul Moon Platinum (58,820 points)

1 Answer

+3 votes
Hi Paul,

I hope this will solve your problem. I had this type of code in past.
<script type="text/javascript">
function SSI_CustomGraphicalCheckbox(GraphicalCheckboxObj, InputObj, blnCheck)  
    {
        if(InputObj.name == "Q1_r21_c1" && blnCheck == true)  
        {  
            document.getElementById("Q1_c2_21").checked = true;
            document.getElementById("Q1_c2_21_graphical").removeClass("radiobox"); 
            document.getElementById("Q1_c2_21_graphical").addClass("radioboxselected");
            var i = 1;
                for (i = 1; i <= 20; i++) 
            {
                document.getElementById("Q1_c2_"+i+"").checked = false;
                document.getElementById("Q1_c2_"+i+"_graphical").removeClass("radioboxselected"); 
                document.getElementById("Q1_c2_"+i+"_graphical").addClass("radiobox");
            }

                  }
  
    }

function SSI_CustomGraphicalRadiobox(GraphicalRadioboxObj, InputObj)  
{ 
    if(InputObj.name == "Q1_c2")  
    {  
        var i = 1;
            for (i = 1; i <= 20; i++) 
        {
            if(InputObj.value==i)
            {
                document.getElementById("Q1_r"+i+"_c1").checked = true;
                document.getElementById("Q1_r"+i+"_c1_graphical").removeClass("checkbox"); 
                document.getElementById("Q1_r"+i+"_c1_graphical").addClass("checkboxselected");
            }
        }
    }
}
</script>
answered Jun 11, 2013 by Rajesh Rana Gold (23,430 points)
...