Have an idea?

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

How to reach out for a select option in a row-by-row-grid

Dear Sawtooth team,

I have a row-by-row-grid in which the last option is "Other" and it should be possible to enter a text.
So far so good.

The specification is that when nothing or another option than option 1 is clicked, the input should be disabled.

So after the script for the row-by-row- display of the grid, I entered the following code:

$('input[name="CA01_r15_other"]').prop('disabled', true);

 if(SSI_GetValue('#CA01_r15_1',true)){
     $('input[name="CA01_r15_other"]').prop('disabled', false);
 }



The code disables the input, but the if condition does not work and disables the whole row-by-row-display.

Can you help what is wrong?

Best regards!
asked Jan 19 by Sarah

1 Answer

0 votes
Two things stick out to me.

First, SSI_GetValue does not support being passed in a second argument.  It seems you want to get the value of this field and check to see if it's true, but the function doesn't know this.  Instead we'd want to do this:

SSI_GetValue('CA01_r15') == 1


Second, even with the conditional fixed, the question that remains is when this code runs.  If we just add this code to the end of the footer, the behavior is going to be that the browser will run this code just once, when the page loads.  But what I think we want is to have this code check everytime the respondent changes their answer.  So we'll need to wrap this code with some sort of event so we can get the code running when we need it to.  Usually we use SSI_CustomGraphicalRadiobox or SSI_CustomGraphicalCheckbox for this, but we actually do it a little differently when the "Better Lighthouse Library" is included on the page.  Please try adding this script to your question and see if it gets you the behavior you want:

<script>
$(document).on('lighthouseRadioButtonChanged', function(event, graphicalObj, inputObj) {
    $('input[name="CA01_r15_other"]').prop('disabled', true);
    if (SSI_GetValue('CA01_r15') == 1) {
        $('input[name="CA01_r15_other"]').prop('disabled', false);
    }
});
</script>
answered Jan 20 by Zachary Platinum Sawtooth Software, Inc. (214,575 points)
That is exactly what I was looking for and it works perfectly fine.

Thanks a lot again!

Best regards
...