Welcome to the LimeSurvey Community Forum

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

Hide matrix subquestions

  • psoliveira
  • psoliveira's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 3 months ago #146541 by psoliveira
Hide matrix subquestions was created by psoliveira
Hi,

I've made a survey, that is currently active, but for now i need to hide some subquestions from a matrix question.
I'm using Limesurvey 2.05+.

Thank you for your help.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago #146542 by Joffm
Replied by Joffm on topic Hide matrix subquestions
Hi, psoliveira,
I can test in 2.06+, but just use relevance in your subquestions.
see screenshots.

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • psoliveira
  • psoliveira's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 3 months ago #146543 by psoliveira
Replied by psoliveira on topic Hide matrix subquestions
Hi Joffm,

Thank you for your answer, but unfortunately i'm using the 2.05+ version and there's no relevance column.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago #146555 by DenisChenu
Replied by DenisChenu on topic Hide matrix subquestions
Then : pre 2.6 solution
demonstration.sondages.pro/676785?lang=fr#

In french, but code are international :)

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 following user(s) said Thank You: psoliveira
The topic has been locked.
  • psoliveira
  • psoliveira's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 3 months ago #146559 by psoliveira
Replied by psoliveira on topic Hide matrix subquestions
Hi DenisChenu,

Thank you for you solution.
Your example needs another question to work as filter, but mine doesn't.
I was thinking something like:
A matrix with 10 subquestion, i want to hide subquestions 1, 2, 3, 6 and 8
$("#question{QID_SQ001}").hide();
$("#question{QID_SQ002}").hide();
$("#question{QID_SQ003}").hide();
$("#question{QID_SQ006}").hide();
$("#question{QID_SQ008}").hide();
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago #146570 by tpartner
Replied by tpartner on topic Hide matrix subquestions
You can remove rows with a script like this in the question source. (note that this may cause problems if the question is mandatory)

Code:
<script type="text/javascript" charset="utf-8">    
 
  $(document).ready(function() {
 
    // Remove rows
    $('#javatbd{SGQ}SQ001').remove();
    $('#javatbd{SGQ}SQ002').remove();
    $('#javatbd{SGQ}SQ003').remove();
    $('#javatbd{SGQ}SQ006').remove();
    $('#javatbd{SGQ}SQ008').remove();
 
    // Fix up the row classes
    var rowClass = 1;
    $('#question{QID} table.subquestions-list tbody tr').each(function(i) {
      if($(this).hasClass('sub-header-row')) {
        rowClass = 1
      }
      else {
        rowClass++;
        $(this).removeClass('array1 array2')
        if(rowClass % 2 == 0) {
          $(this).addClass('array2');
        }
        else {
          $(this).addClass('array1');
        }
      }
    });
  });
</script>

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: psoliveira
The topic has been locked.
  • psoliveira
  • psoliveira's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 3 months ago #146574 by psoliveira
Replied by psoliveira on topic Hide matrix subquestions
Hi tpartner,

Your solution worked fine and was exactly what i need (the question is not mandatory).
Thank you very much.
I was triyng to adapt a code from DenisChenu, on another question that also was working, but i think yours is more complete.
Here was my solution:
Code:
<script>
  $(function() {
    $('#javatbd{SGQ}SQ001').hide();
    $('#javatbd{SGQ}SQ002').hide();
    $('#javatbd{SGQ}SQ003').hide();
    $('#javatbd{SGQ}SQ006').hide();
    $('#javatbd{SGQ}SQ008').hide();
  });
</script>
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago #146576 by tpartner
Replied by tpartner on topic Hide matrix subquestions
That's very close to mine but I prefer to remove the rows instead of hiding in case someone is tabbing through the form.

I also like to fix the alternating row colours after removing rows.

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 3 months ago #146601 by DenisChenu
Replied by DenisChenu on topic Hide matrix subquestions

tpartner wrote: That's very close to mine but I prefer to remove the rows instead of hiding in case someone is tabbing through the form.

If i don't make error : an input inside an hidden (display:none} element can not be tabbed ?

No ?

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 3 months ago #146616 by tpartner
Replied by tpartner on topic Hide matrix subquestions
Dunno, but I don't trust some browsers.

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: DenisChenu
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose