Have an idea?

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

Using Javascript with SSI_CustomGraphicalCheckbox, combobox items disappear...

Hi all,

I have a grid with 5 row. The first 3 rows are comboboxes, the 2 last rows are checkboxes.

If one of the checkboxes is checked,  reset the comboboxes.
If one of the comboboxes change, reset the 2 checkboxes .

I wrote this piece of javascript that should work but...

Each part works fine independently (the Javascript part, and the SSI_CustomGraphicalCheckbox function part).

When I put the two parts together, the values in the comboboxes are not displayed anymore !
If I select something, the empty default value remains displayed.

Am I doing something wrong or is it a bug ?
What can I do to have it working as expected ?

Thanks for your help !

<script type="text/javascript">
        SSI_SetSelect('[% QuestionName() %]_r4_c1',false);
        SSI_SetSelect('[% QuestionName() %]_r5_c1',false);
function SSI_CustomGraphicalCheckbox(GraphicalCheckboxObj, InputObj, blnCheck){
    if(InputObj.name == "[% QuestionName()%]_r4_c1" || InputObj.name == "[% QuestionName()%]_r5_c1"  && blnCheck == true){
        $('#[% QuestionName() %]_r1_c1').val('');
        $('#[% QuestionName() %]_r2_c1').val('');
        $('#[% QuestionName() %]_r3_c1').val('');
}//EO SSI_Function    

asked Feb 19, 2018 by phronexia Bronze (3,170 points)

1 Answer

+1 vote
Best answer
I believe you have an operator precedence problem.  Add another pair of parentheses on line 9:

if((InputObj.name == "[% QuestionName()%]_r4_c1" || InputObj.name == "[% QuestionName()%]_r5_c1") && blnCheck == true){
answered Feb 19, 2018 by Zachary Platinum Sawtooth Software, Inc. (206,100 points)
selected Feb 19, 2018 by phronexia
Thanks Zachary ! As usual you solved my problem :)
It works like a charm