Have an idea?

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

Display question in Gray Hidden

Hi All,

I have create a question pre-select and I want that question pre-select display in gray, it will cannot edit but still store in data when export.

Look like below:

https://drive.google.com/file/d/1MN3hVr4jn8koqyPRmXTj7QbRIplndgCT/view?usp=sharing
asked Jul 16 by Saroeun Bronze (2,715 points)

1 Answer

+1 vote
 
Best answer
The "Better Lighthouse Library" in the Community Question Library comes with easy-to-use functions for disabling radio buttons and checkboxes.  If you haven't already, you can download it from here and import it into your local question library:

https://sawtoothsoftware.com/resources/question-library/better-lighthouse-library

With the BLL included on the page, adding this script to your select question will disable all response options:

<script>
$(document).ready(function(){
    $('input[name="hid_list_[% QuestionName() %]"]').val().split(',').forEach(function(item){
        SSI_DisableRadioButtonOrCheckbox('[% QuestionName() %]_' + item);
    });
})
</script>


To pre-select some responses, add lines of code like this before line 3, replacing "1" with the item to check:

SSI_SetSelect('[% QuestionName() %]_1', true);
answered Jul 16 by Zachary Platinum Sawtooth Software, Inc. (184,925 points)
selected Jul 16 by Saroeun
Wow, perfect. Thanks so much Zachary.
Zachary, I need your help again.

With this script how can I hide question type Numeric or Open-End?

Thanks
You don't need the BLL for <input> or <textarea> elements.  You can disable those questions with code like this:

<script>
$(document).ready(function(){
    $('#[% QuestionName() %]').prop('disabled', true);
})
</script>
Thanks Zachary,

When I used, it working well but when I export data it not store data in those column. How can I get data?
My code doesn't do anything data related, it just prevents the data in the element from being altered through normal methods.  Are you looking to set a response to the field before disabling it?  You could try adding this before the disabling to edit the response:

$('#[% QuestionName() %]').val('hello world');
...