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

More
8 years 7 months ago #123980 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.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 7 months ago #123996 by holch
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.
More
8 years 7 months ago #124012 by ajish
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.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 7 months ago #124030 by tpartner

When I update to 2.06 all my changes are lost.

There should be nothing "lost" when updating but always back up first.

...please tell me how to hide blank subquestions / answers in 2.05 of List (radio) and Multiple choice question type.

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)
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.
More
8 years 7 months ago #124033 by ajish
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.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 7 months ago #124035 by holch
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.

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.
More
8 years 7 months ago #124225 by ajish
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.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 7 months ago #124246 by holch
you need to create the same answer options as in the previous question.

Then, if you put something like
Code:
V001.NAOK != 'A1'
it will show this specific answer option if the answer to V001 is NOT 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.
More
8 years 6 months ago #124347 by ajish
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.
The topic has been locked.
More
7 years 11 months ago #134826 by Ni3
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>
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago #134832 by tpartner
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.
More
7 years 11 months ago #134893 by Ni3
I am using 2.05 version
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose