Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

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

  • SherriChen
  • SherriChen's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 years 9 months 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!
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 9 months ago - 4 years 9 months ago #185863 by Joffm
Hi,
here you find a working example survey how to disable the input fields.
www.limesurvey.org/forum/can-i-do-this-w...-matrix-cells#185706

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 years 9 months ago by Joffm.
The topic has been locked.
  • SherriChen
  • SherriChen's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 years 9 months ago #185866 by SherriChen
Thank you, Joffm! It works perfectly!
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 9 months 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.
The following user(s) said Thank You: DenisChenu, Joffm
The topic has been locked.
  • SherriChen
  • SherriChen's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 years 9 months ago #185893 by SherriChen
Thank you, tpartner! It works great!
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 9 months 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
The topic has been locked.
  • SherriChen
  • SherriChen's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 years 9 months 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!
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 9 months 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
The topic has been locked.
  • SherriChen
  • SherriChen's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 years 9 months 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
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 9 months 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.
The topic has been locked.
  • SherriChen
  • SherriChen's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 years 9 months 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.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 9 months 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
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose