How to make one column in an array text question "readonly"?

More
2 months 14 hours ago #185858 by SherriChen
Hi,

I need an array question which contains 3 columns:
Column 1-"Food items"
Column 2- "Measure unit"
Column 3- "Amounts per week"

I want to prefill something in Column 2 and make this column read-only, so that respondents cannot change it.

Is it possible to achieve it in LS 3.x?
Thank you for your help!

Please Log in or Create an account to join the conversation.

LimeSurvey Partners
More
2 months 12 hours ago - 2 months 12 hours ago #185863 by Joffm
Hi,
here you find a working example survey how to disable the input fields.
https://www.limesurvey.org/forum/can-i-do-this-with-limesurvey/118642-javascript-for-input-based-formula-calculation-in-matrix-cells#185706

Best regards
Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 months 12 hours ago by Joffm.

Please Log in or Create an account to join the conversation.

More
2 months 9 hours ago #185866 by SherriChen
Thank you, Joffm! It works perfectly!

Please Log in or Create an account to join the conversation.

More
1 month 4 weeks ago #185887 by tpartner
Be careful with disabling inputs - this will prevent their value being recorded in the data. You can use .prop('readonly', true) instead.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
The following user(s) said Thank You: DenisChenu, Joffm

Please Log in or Create an account to join the conversation.

More
1 month 4 weeks ago #185893 by SherriChen
Thank you, tpartner! It works great!

Please Log in or Create an account to join the conversation.

More
1 month 4 weeks ago #185899 by Joffm
Yes, an important remark of tpartner.

You see, it was not my script. The TE provided it in his question.

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in or Create an account to join the conversation.

More
1 month 4 weeks ago #185901 by SherriChen
Hi Joffm,

Your script also works and it helps me solve another problem about inserting different select options into different cells. I just update your script with Tpartner's suggestions. Whatever, thank you very much for your help!

Please Log in or Create an account to join the conversation.

More
1 month 4 weeks ago #185903 by Joffm
Yes, therefore I sent the whole survey.
Because there are other interesting things to learn included.

And I informed the TE of the other thread about Tony's suggestion.

Best wishes to Eindhoven

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in or Create an account to join the conversation.

More
1 month 4 weeks ago #185910 by SherriChen
Sorry, I come again. I meet a similar problem in another array text question.
Please see the picture below, I want to make cells in Column 3 read-only only if people choose "3" in Column 2. Is it possible to do this?


File Attachment:

File Name: limesurvey...4867.lss
File Size:19 KB
Attachments:

Please Log in or Create an account to join the conversation.

More
1 month 4 weeks ago #185911 by tpartner
Do you also want to delete any value in column-3 if 3 is selected in column-2?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com

Please Log in or Create an account to join the conversation.

More
1 month 4 weeks ago #185912 by SherriChen
No. If people choose "1" or "2", they need to answer question in Column-3. If they choose "3", the column-3 in this row will turn grey and people don't need to answer it.

Please Log in or Create an account to join the conversation.

More
1 month 4 weeks ago #185914 by Joffm
Hi,
just something to consider:
IMO you are sticking to some preconceived ideas regarding the design of your survey without having done some prototyping to see what is possible out of the box and what is not.

Sometimes I think the students asking questions here saw an illustration in a book and now the look and feel of their question has to be exactly like that.
Generally: More simple questions are always better than many different things in one array.

For example here:
You can solve this very easily by splitting the question.
If the question of column 3 is a separate question, you can use relevance equation to display or not according to the answer in column 2 (without any javascript "tricks").



Just to give you an idea

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:

Please Log in or Create an account to join the conversation.

More
1 month 4 weeks ago #185917 by SherriChen
Hi Joffm,

Yes, I agree with you. But I am working on a complex questionnaire including many questions of respondents' history. For example, in this case, the original question is asking about people's illness history. The table will contain "illness" "When were you diagnosed with this illness?" "Have you recovered from this illness?" "If yes, when did you recover from this illness?" "Relapse or not?" The questions are continuous and we don't know how many experiences the respondent has. So I think it's better to achieve it in an array. If Limesurvey cannot do this, I will choose your solution. Thank you!

Please Log in or Create an account to join the conversation.

More
1 month 4 weeks ago #185928 by SherriChen
Hi,

Good news! I think I have solved this problem with the following code:

<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('input[ name="{SGQ}SQ001_SQ002"]').change(function() {
$('input[ name="{SGQ}SQ001_SQ003"]').prop('disabled', true);
$('input[name="{SGQ}SQ001_SQ003"]').val("");
if ($('input[ name="{SGQ}SQ001_SQ002"]').val()=="3") {
$('input[ name="{SGQ}SQ001_SQ003"]').prop('disabled', false);
$('input[name="{SGQ}SQ001_SQ003"]').val("");
}
});

});

</script>


:laugh:

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!