- Posts: 43
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Conditionally set dropdown list to disabled
- mcovents
- Topic Author
- Offline
- Senior Member
Less
More
3 years 7 months ago #204895
by mcovents
Conditionally set dropdown list to disabled was created by mcovents
I want to set a dropdown list conditionally to disabled similar to the solution below which works for a text input.
forums.limesurvey.org/forum/can-i-do-thi...on-input-to-disabled
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:complete',function() {
var lockit = '{DisableThem.NAOK}';
if (lockit == 'Y') {
$("#answer123432X6804X55061").prop('readonly', true);
}
else {
$("#answer123432X6804X55061").prop('readonly', false);
}
});
</script>
How can I update the code to make it work for a dropdown list?
forums.limesurvey.org/forum/can-i-do-thi...on-input-to-disabled
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:complete',function() {
var lockit = '{DisableThem.NAOK}';
if (lockit == 'Y') {
$("#answer123432X6804X55061").prop('readonly', true);
}
else {
$("#answer123432X6804X55061").prop('readonly', false);
}
});
</script>
How can I update the code to make it work for a dropdown list?
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5033
- Thank you received: 1257
3 years 7 months ago #204902
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Conditionally set dropdown list to disabled
You should provide the LimeSurvey version you use. Workarounds often only work in certain versions. You might provide a LSS export of an example survey with just the one question the workaround should be applied too as well.
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
- mcovents
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 43
- Thank you received: 0
3 years 7 months ago #204903
by mcovents
Replied by mcovents on topic Conditionally set dropdown list to disabled
I work with Limesurvey 3.15.5+181115
In attachment you can find the lss.
If you enter Y in the DisableFields question the two other questions (tekst and lijst) should be disabled.
This is working for the tekst question but not for the lijst question which is of a different type (dropdown)
Thank you for your response,
In attachment you can find the lss.
If you enter Y in the DisableFields question the two other questions (tekst and lijst) should be disabled.
This is working for the tekst question but not for the lijst question which is of a different type (dropdown)
Thank you for your response,
Attachments:
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12935
- Thank you received: 3979
3 years 7 months ago #204904
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Conditionally set dropdown list to disabled
You want to disable the whole question?
Why not use relevance equation (to hide the question)?
DisableFields!="Y"
Or ist there something else you did not mention yet?
Joffm
Why not use relevance equation (to hide the question)?
DisableFields!="Y"
Or ist there something else you did not mention yet?
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- mcovents
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 43
- Thank you received: 0
3 years 7 months ago #204907
by mcovents
Replied by mcovents on topic Conditionally set dropdown list to disabled
We want the information to remain visible.
The purpose of this is the following.
The survey has to be completed by two persons subsequently.
We want to create an expense report application. The person declaring his expenses fills in the survey. Next the supervisor receives an email with a link to the same survey so he can view the data entered. This supervisor enters a password in the DisableFields question which disables the questions filled in by the first person so he is not able to change the declaration (for example change the amount declared) This password field also unhides an approval question so the supervisor can accept or reject the declaration.
In a third step after approval the first person enters his final expenses.
If we use relevance equation to hide a question the data entered is lost.
The purpose of this is the following.
The survey has to be completed by two persons subsequently.
We want to create an expense report application. The person declaring his expenses fills in the survey. Next the supervisor receives an email with a link to the same survey so he can view the data entered. This supervisor enters a password in the DisableFields question which disables the questions filled in by the first person so he is not able to change the declaration (for example change the amount declared) This password field also unhides an approval question so the supervisor can accept or reject the declaration.
In a third step after approval the first person enters his final expenses.
If we use relevance equation to hide a question the data entered is lost.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
3 years 7 months ago - 3 years 7 months ago #204910
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Conditionally set dropdown list to disabled
There is no "readonly" property available for select (dropdown) elements.
If you use the "disabled" property, the data will not be recorded.
If you use the "disabled" property, the data will not be recorded.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 3 years 7 months ago by tpartner.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
- mcovents
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 43
- Thank you received: 0
3 years 7 months ago #204911
by mcovents
Replied by mcovents on topic Conditionally set dropdown list to disabled
Any suggestions?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
3 years 7 months ago #204915
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Conditionally set dropdown list to disabled
Use Javascript or CSS to hide the dropdown, use Expression Script to display its value.
I'm not in a position this week to give detailed examples.
I'm not in a position this week to give detailed examples.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13648
- Thank you received: 2491
3 years 7 months ago #204927
by DenisChenu
With dropdown where i need value submitted but need a "readonly" system : i add disabled property at all not selected value
It work
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Conditionally set dropdown list to disabled
Yep,tpartner wrote: There is no "readonly" property available for select (dropdown) elements.
If you use the "disabled" property, the data will not be recorded.
With dropdown where i need value submitted but need a "readonly" system : i add disabled property at all not selected value
It work
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- mcovents
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 43
- Thank you received: 0
3 years 7 months ago #204930
by mcovents
Replied by mcovents on topic Conditionally set dropdown list to disabled
Can you give me example code to disable all not selected values in a dropdown list?
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13648
- Thank you received: 2491
3 years 7 months ago #205064
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Conditionally set dropdown list to disabled
In question text edition,
Something like this
Something like this
Code:
<script> $(document).on('ready',function() { var lockit = '{DisableThem.NAOK}'; if (lockit == 'Y') { var currentValue = $("#answer{SGQ}").val(); $("#answer{SGQ} select option").each(function() { if ( $(this).attr('value') != currentValue) { $(this).prop('disabled',true); } } } }); </script>
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.