Have an idea?

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

Mutually de-select radio-button and checkbox

Dear All,

Im using SSI v7 and need to enable on one page to mutually de-select radio-button and checkbox.  So if you select any checkbox it should deselect radio-button, if is selected radio-button it should deselect all checkbox cells.
Data Cell:
Q16_a_1   to  Q16_a_5  are checkbox
Q16_b   is radio-button.

Have used below code (in a footer) and although it deselects  checkbox, it doesn't deselects radio-button.
Unfortunatelly function SSI_RadioReset was introduced from v8.
Could you please help ?

<script type="text/javascript">
function SSI_CustomGraphicalCheckbox(GraphicalCheckboxObj, InputObj, blnCheck)
{
    if(InputObj.name == "Q16_a_1" && blnCheck == true)
    {
                $("#Q16_b").removeClass("radiobox");
                $("#Q16_b").addClass("radioboxselected");
    }
    if(InputObj.name == "Q16_a_2" && blnCheck == true)
    {
                $("#Q16_b").removeClass("radiobox");
                $("#Q16_b").addClass("radioboxselected");   
    }
    if(InputObj.name == "Q16_a_3" && blnCheck == true)
    {
                $("#Q16_b").removeClass("radiobox");
                $("#Q16_b").addClass("radioboxselected");   
    }
    if(InputObj.name == "Q16_a_4" && blnCheck == true)
    {
                $("#Q16_b").removeClass("radiobox");
                $("#Q16_b").addClass("radioboxselected");   
    }
    if(InputObj.name == "Q16_a_5" && blnCheck == true)
    {
                $("#Q16_b").removeClass("radiobox");
                $("#Q16_b").addClass("radioboxselected"); 
    }
}
function SSI_CustomGraphicalRadiobox(GraphicalRadioboxObj, InputObj)
{
    if(InputObj.name == "Q16_b")
    {
        SSI_SetSelect("Q16_a_1", false);
        SSI_SetSelect("Q16_a_2", false);
        SSI_SetSelect("Q16_a_3", false);
        SSI_SetSelect("Q16_a_4", false);
        SSI_SetSelect("Q16_a_5", false);
    }
}
</script>



All the best!
Robson
asked Oct 30 by robson Bronze (595 points)
retagged Oct 30 by Walter Williams

1 Answer

+1 vote
You've got a good start with your SSI_CustomGraphicalCheckbox code.  You will want to replace "radioboxselected" with "radiobox," but this needs to be done to the graphical element "Q16_b_graphical" element instead of to the input element itself.  For the input element itself, you can just set the checked state to false:

function SSI_CustomGraphicalCheckbox(GraphicalCheckboxObj, InputObj, blnCheck)
{
    if (blnCheck && /^Q16_a_/.test(InputObj.name))
    {
        document.getElementById('Q16_b_1').checked = false;
        document.getElementById('Q16_b_1_graphical').classList.remove('radioboxselected');
        document.getElementById('Q16_b_1_graphical').classList.add('radiobox');
    }
}
answered Oct 30 by Zachary Platinum Sawtooth Software, Inc. (63,475 points)
Thank you very much Zachary!
Works perfect!  You are great programmer  !
Problem with Internet Explorer
...