Welcome to the LimeSurvey Community Forum

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

Hide next question by answering previous one

  • Stan
  • Stan's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 8 months ago #138964 by Stan
Hi, i would like to simply hide a question Q2 when the direct previous question Q1 (multiple choice) is answered through Checkbox (click).
I tried some EM and Javascript without success and may Need some help.
Using Version 2.50+ Build160606

This is what i've tried
Code:
 <script type="text/javascript" charset="utf-8">  
  $(document).ready(function() {
      // Identify the questions
    var this = $('#Q1{ID}');
    var nextQuestion = $(thisQuestion).next('div[id^="question"]');
     if ($(this).is(':checked')) {
        $(this).(nextQuestion).hide();
    }
    else{
        $(this).(nextQuestion).show();
    }
});
 
</script>
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 8 months ago #138965 by tpartner
Replied by tpartner on topic Hide next question by answering previous one
You should be able to use Expression manager relevance like this:

Code:
Q1_SQ001 != 'Y'

Sample survey attached:

File Attachment:

File Name: limesurvey...22-2.lss
File Size:21 KB

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: Stan
The topic has been locked.
  • Stan
  • Stan's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 8 months ago #138966 by Stan
Thank you!
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 8 months ago #138983 by DenisChenu
Replied by DenisChenu on topic Hide next question by answering previous one
Hi,

Just one question:
Code:
// Identify the questions
    var this = $('#Q1{ID}');
Where do you find this ?
#question{Q1.qid} or #answer{Q1.sgq} why not, but where did you found #Q1{ID} ????

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.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 8 months ago #138989 by tpartner
Replied by tpartner on topic Hide next question by answering previous one
I didn't address any JavaScript issues because it's not required.

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
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 8 months ago #138990 by DenisChenu
Replied by DenisChenu on topic Hide next question by answering previous one
Yes, and your solution is really better :).
But i want to know where Stan found this instructions :). Maybe some error in manual :)

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.
  • Stan
  • Stan's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 8 months ago #139276 by Stan

DenisChenu wrote: But i want to know where Stan found this instructions :). Maybe some error in manual :)

Hi, this has nothing to do with the Manual. i just tried to fix the issue by writing my own Javascript code. Then i posted it here, so that someone could eventually show me what is wrong with that code (so thanks for your corrections), or propose a better way like tpartner did.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose