- Posts: 5
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Can I hide a particular subquestion or answer using Expression Manager
- ajish
- Topic Author
- Offline
- New Member
Less
More
8 years 9 months ago #123980
by ajish
Can I hide a particular subquestion or answer using Expression Manager was created by ajish
Hi,
I need to hide an answer of a List (radio) question type and a subquestion of a Multiple choice question type. I need to use the Expression Manager syntax for this like
{if( V001.NAOK != 'A1', 'The answer /subquestion', 'Hide the answer /subquestion' )}
in the Answer / Subquestion textbox option in the Edit answer options page / Edit subquestions page;
where V001 is the first question code & A1 is one of its Answer / Subquestion code.
I need to hide the answer /subquestion of the second question using Expression Manager syntax because Expression Manager syntax is easy and the client dont know javascript .
Please help me to achieve this. Thanks a lot.
I need to hide an answer of a List (radio) question type and a subquestion of a Multiple choice question type. I need to use the Expression Manager syntax for this like
{if( V001.NAOK != 'A1', 'The answer /subquestion', 'Hide the answer /subquestion' )}
in the Answer / Subquestion textbox option in the Edit answer options page / Edit subquestions page;
where V001 is the first question code & A1 is one of its Answer / Subquestion code.
I need to hide the answer /subquestion of the second question using Expression Manager syntax because Expression Manager syntax is easy and the client dont know javascript .
Please help me to achieve this. Thanks a lot.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11724
- Thank you received: 2756
8 years 9 months ago #123996
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Can I hide a particular subquestion or answer using Expression Manager
Depends on the version you use. Since 2.06 you can use the expression manager to hide subquestions/answer options. There is a field for the expression just behind the answer option in the admin menu.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- ajish
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
8 years 9 months ago #124012
by ajish
Replied by ajish on topic Can I hide a particular subquestion or answer using Expression Manager
Hi Holch,
Thanks for your reply.
I am using Limesurvey 2.05. Is it possible in that?
When I update to 2.06 all my changes are lost. But I backup-ed that.
If it is not possible in 2.05 please tell me how to hide blank subquestions / answers in 2.05 of List (radio) and Multiple choice question type. So I can use
{if( V001.NAOK != 'A1', 'The answer /subquestion', '' )}
which results in blank subquestion / answer.
Thank you very much.
Thanks for your reply.
I am using Limesurvey 2.05. Is it possible in that?
When I update to 2.06 all my changes are lost. But I backup-ed that.
If it is not possible in 2.05 please tell me how to hide blank subquestions / answers in 2.05 of List (radio) and Multiple choice question type. So I can use
{if( V001.NAOK != 'A1', 'The answer /subquestion', '' )}
which results in blank subquestion / answer.
Thank you very much.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10134
- Thank you received: 3603
8 years 9 months ago #124030
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 Can I hide a particular subquestion or answer using Expression Manager
There should be nothing "lost" when updating but always back up first.When I update to 2.06 all my changes are lost.
Place the following script in the source of a list-radio or multiple-choice question to hide all answers or sub-questions that have blank labels. (note, this only fires on page-load)...please tell me how to hide blank subquestions / answers in 2.05 of List (radio) and Multiple choice question type.
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { $('#question{QID} label.answertext').each(function(i) { if($.trim($(this).text()) == '') { $(this).prev('input.radio, input.checkbox').prop('checked', false); $(this).next('input[type="hidden"]').attr('value', ''); $(this).closest('li.answer-item').hide(); } }); }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- ajish
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
8 years 9 months ago #124033
by ajish
Replied by ajish on topic Can I hide a particular subquestion or answer using Expression Manager
Hi Tony Partner,
Thank you very much for the reply.
But the client dont know javascript and the script only fires on page-load. So I have to use Expression Manager only like
{if( V001.NAOK != 'A1', 'The answer /subquestion', '' )}
which results in blank subquestion / answer. Can you please tell me a solution to hide this with Expression Manager syntax without javascript or any other way to hide the blank subquestion / answer.
Thanks a lot.
Thank you very much for the reply.
But the client dont know javascript and the script only fires on page-load. So I have to use Expression Manager only like
{if( V001.NAOK != 'A1', 'The answer /subquestion', '' )}
which results in blank subquestion / answer. Can you please tell me a solution to hide this with Expression Manager syntax without javascript or any other way to hide the blank subquestion / answer.
Thanks a lot.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11724
- Thank you received: 2756
8 years 9 months ago #124035
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Can I hide a particular subquestion or answer using Expression Manager
As mentioned before, hiding subquestions via expression manager/relevance equations was implemented in 2.06. Before that, it is not possible.
Tony posted a work around that should work for versions before 2.06. This requires Javascript.
These are your two options. There is no way to do this with expression manager before 2.06.
Tony posted a work around that should work for versions before 2.06. This requires Javascript.
These are your two options. There is no way to do this with expression manager before 2.06.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The following user(s) said Thank You: tpartner, ajish
The topic has been locked.
- ajish
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
8 years 9 months ago #124225
by ajish
Replied by ajish on topic Can I hide a particular subquestion or answer using Expression Manager
Hi,
Thanks a lot for your reply.
If I use
{if( V001.NAOK != 'A1', 'The answer /subquestion', '' )}
in the Answer / Subquestion textbox option in the Edit answer options page / Edit subquestions page of the second question V002 ;
where V001 is the first question code & A1 is one of its Answer / Subquestion code and this option is checked in the second question V002. Then if I use
{V002.shown}
in the third question V003 I only get
" {if( V001.NAOK != 'A1', 'The answer /subquestion', '' )} "
and not its result. Any solution for this?
Thank you very much.
Thanks a lot for your reply.
If I use
{if( V001.NAOK != 'A1', 'The answer /subquestion', '' )}
in the Answer / Subquestion textbox option in the Edit answer options page / Edit subquestions page of the second question V002 ;
where V001 is the first question code & A1 is one of its Answer / Subquestion code and this option is checked in the second question V002. Then if I use
{V002.shown}
in the third question V003 I only get
" {if( V001.NAOK != 'A1', 'The answer /subquestion', '' )} "
and not its result. Any solution for this?
Thank you very much.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11724
- Thank you received: 2756
8 years 9 months ago #124246
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Can I hide a particular subquestion or answer using Expression Manager
you need to create the same answer options as in the previous question.
Then, if you put something like
it will show this specific answer option if the answer to V001 is NOT A1.
Then, if you put something like
Code:
V001.NAOK != 'A1'
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- ajish
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
8 years 8 months ago #124347
by ajish
Replied by ajish on topic Can I hide a particular subquestion or answer using Expression Manager
Hi,
Thanks a lot for your reply.
Actually my expression manager code is working if the 1st, 2nd & 3rd questions are on different pages (Question by question - Format). But dont works if all on one page. Below is the expression manager code.
I used
{if( V001.NAOK != 'A1', 'The answer /subquestion', '' )}
in the Answer textbox option in the Edit answer options page of the second question V002 ;
where V001 is the first question code & A1 is one of its Answer code and this option is checked in the second question V002. Then I used
{V002.shown}
in the third question's text V003 (not in its answer option) I only get
" {if( V001.NAOK != 'A1', 'The answer /subquestion', '' )} "
the expression manager code and not its result. Any solution for this if all the questions are on the same page?
Thanks.
Thanks a lot for your reply.
Actually my expression manager code is working if the 1st, 2nd & 3rd questions are on different pages (Question by question - Format). But dont works if all on one page. Below is the expression manager code.
I used
{if( V001.NAOK != 'A1', 'The answer /subquestion', '' )}
in the Answer textbox option in the Edit answer options page of the second question V002 ;
where V001 is the first question code & A1 is one of its Answer code and this option is checked in the second question V002. Then I used
{V002.shown}
in the third question's text V003 (not in its answer option) I only get
" {if( V001.NAOK != 'A1', 'The answer /subquestion', '' )} "
the expression manager code and not its result. Any solution for this if all the questions are on the same page?
Thanks.
The topic has been locked.
- Ni3
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
8 years 1 month ago #134826
by Ni3
Replied by Ni3 on topic Can I hide a particular subquestion or answer using Expression Manager
Hi tpartner,
I want to hide the subquestion of Multiple short text. I tried using the above code (changing the multiple-short-txt) but not working. I am sure i am making some mistake while changing code.
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#question{QID} label.answertext').each(function(i) {
if($.trim($(this).text()) == '') {
$(this).next('input[type="hidden"]').attr('value', '');
$(this).closest('.multiple-short-txt ul.subquestions-list li').hide();
}
});
});
</script>
I want to hide the subquestion of Multiple short text. I tried using the above code (changing the multiple-short-txt) but not working. I am sure i am making some mistake while changing code.
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#question{QID} label.answertext').each(function(i) {
if($.trim($(this).text()) == '') {
$(this).next('input[type="hidden"]').attr('value', '');
$(this).closest('.multiple-short-txt ul.subquestions-list li').hide();
}
});
});
</script>
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10134
- Thank you received: 3603
8 years 1 month ago #134832
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 Can I hide a particular subquestion or answer using Expression Manager
What is your LimeSurvey version?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- Ni3
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
8 years 1 month ago #134893
by Ni3
Replied by Ni3 on topic Can I hide a particular subquestion or answer using Expression Manager
I am using 2.05 version
The topic has been locked.