Welcome to the LimeSurvey Community Forum

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

Hide column in array question

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 7 months ago #230663 by tpartner
Replied by tpartner on topic Hide column in array question
The HTML changes have been reverted - bugs.limesurvey.org/view.php?id=18276#c71177

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: holch, ecoplan

Please Log in to join the conversation.

More
2 years 7 months ago #230715 by ecoplan
Replied by ecoplan on topic Hide column in array question
that was fast! thanks for pushing this. we have 60+ surveys running atm with lots scripts from the forum. in the end I'm even more confident with LS. thanks!

Please Log in to join the conversation.

More
2 years 6 months ago - 2 years 6 months ago #231524 by IDEA_Rozwoju
Replied by IDEA_Rozwoju on topic Hide column in array question
What if I wanted to hide only the last column, without filtering on the previous questions (the last column contains the answers automatically filled in, for the answer "other").

In the past (version 2.06+) the following code, developed by tpartner, worked like a dream:
Code:
<script type="text/javascript" charset="utf-8">  
 
  $(document).ready(function() { 
 
    // Identify this question
    var thisQuestion = $('#question'+{QID}+'');
 
    // Add some column-specific classes
    $('table.subquestions-list tr', thisQuestion).each(function(i){
      $('> *', this).each(function(i){
        $(this).addClass('column-'+(i+1));
      });
    });
 
    // Hide all column-1 elements
    $('.column-1', thisQuestion).hide();   
    $('table.subquestions-list col', thisQuestion).css('width', 'auto');
 
  });
</script>

Now (5.3.31 version) this code is unfortunately not working.
Last edit: 2 years 6 months ago by IDEA_Rozwoju.

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 6 months ago #231556 by tpartner
Replied by tpartner on topic Hide column in array question
You didn't tell us what type of array so I'm going to assume an array-texts.

If you only want to hide the last column, I would do it with CSS rather than JS in the question source:

Code:
<style type="text/css" data-author="Tony Partner">
 
  #question{QID} .subquestion-list col:last-child,
  #question{QID} .subquestion-list th:last-child,
  #question{QID} .subquestion-list td:last-child {
    display: none !important;
  }
 
  #question{QID} .subquestion-list col {
    width: auto !important;
  }
</style>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

More
2 years 6 months ago - 2 years 6 months ago #231630 by IDEA_Rozwoju
Replied by IDEA_Rozwoju on topic Hide column in array question
Dear tpartner, thank you so much it works great (also for basic array - with radio buttons).
 
Last edit: 2 years 6 months ago by IDEA_Rozwoju.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose