- Posts: 43
- Thank you received: 0
- Forum
- English support forums
- Can I do this with LimeSurvey?
- How to make one column in an array text question "readonly"?
How to make one column in an array text question "readonly"?
- SherriChen
-
Topic Author
- Offline
- Senior Lime
-
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.
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
Please Log in or Create an account to join the conversation.
- SherriChen
-
Topic Author
- Offline
- Senior Lime
-
- Posts: 43
- Thank you received: 0
Please Log in or Create an account to join the conversation.
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.
- SherriChen
-
Topic Author
- Offline
- Senior Lime
-
- Posts: 43
- Thank you received: 0
Please Log in or Create an account to join the conversation.
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.
- SherriChen
-
Topic Author
- Offline
- Senior Lime
-
- Posts: 43
- Thank you received: 0
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.
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.
- SherriChen
-
Topic Author
- Offline
- Senior Lime
-
- Posts: 43
- Thank you received: 0
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?
Please Log in or Create an account to join the conversation.
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.
- SherriChen
-
Topic Author
- Offline
- Senior Lime
-
- Posts: 43
- Thank you received: 0
Please Log in or Create an account to join the conversation.
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.
- SherriChen
-
Topic Author
- Offline
- Senior Lime
-
- Posts: 43
- Thank you received: 0
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.
- SherriChen
-
Topic Author
- Offline
- Senior Lime
-
- Posts: 43
- Thank you received: 0
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>

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