Have an idea?

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

Need Exclusive None of these in Free Format Checkbox Question

I need to use free format for a check box question which has 21 items grouped into sections plus an exclusive None of these option at the end What code do I need to use to make sure that this last option is exclusive in this free format checkbox question. It currently looks like this
    <tr class="clickable">
        <td class="input_cell">
            [%CheckSelect(Q9_va, 22)%]
        </td>
        <td>
            None of these
        </td>
    </tr>

Any help is appreciated!
asked Dec 20, 2016 by rinsights (410 points)

1 Answer

+1 vote
We can use SSI_CustomGraphicalCheckbox to know when a checkbox is checked or unchecked then use SSI_SetSelect to set the checkbox values as necessary:

<script>
function SSI_CustomGraphicalCheckbox(graphicalObj, inputObj, bln) {
    var match = inputObj.name.match(/Q9_va_([0-9]+)/);
    if (match !== null && bln) {
        if (Number(match[1]) == 22) {
            for (var i = 1; i <= 21; i++) {
                SSI_SetSelect('Q9_va_' + i, false);
            }
        }
        else {
            SSI_SetSelect('Q9_va_22', false);
        }
    }
}
</script>
answered Dec 20, 2016 by Zachary Platinum Sawtooth Software, Inc. (63,900 points)
Thank you! It works
...