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

Plus d'informations
il y a 7 mois 3 semaines #185858 par 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!

Connexion ou Créer un compte pour participer à la conversation.

LimeSurvey Partners
Plus d'informations
il y a 7 mois 3 semaines - il y a 7 mois 3 semaines #185863 par 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
Dernière édition: il y a 7 mois 3 semaines par Joffm.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 7 mois 3 semaines #185866 par SherriChen
Thank you, Joffm! It works perfectly!

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 7 mois 3 semaines #185887 par 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
Les utilisateur(s) suivant ont remercié: DenisChenu, Joffm

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 7 mois 3 semaines #185893 par SherriChen
Thank you, tpartner! It works great!

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 7 mois 3 semaines #185899 par 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

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 7 mois 3 semaines #185901 par 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!

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 7 mois 3 semaines #185903 par 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

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 7 mois 3 semaines #185910 par 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?


Fichier attaché :

Nom du fichier : limesurvey...4867.lss
Taille du ficher :19 ko
Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 7 mois 3 semaines #185911 par 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

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 7 mois 3 semaines #185912 par 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.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 7 mois 3 semaines #185914 par 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
Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 7 mois 3 semaines #185917 par 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!

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 7 mois 3 semaines #185928 par 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:

Connexion ou Créer un compte pour participer à la conversation.

Commencez dès maintenant !

Créez simplement un compte et commencez à utiliser LimeSurvey dès aujourd'hui.

Inscrivez-vous maintenant

Inscrivez-vous à notre Newsletter!