Welcome to the LimeSurvey Community Forum

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

explanatory heading in array subquestion

  • barbacot
  • barbacot's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 8 months ago #110514 by barbacot
I need to add an explanatory heading common to all subquestions in the array - see attached screenshot.
I saw a solution here but it was for the answers - how can
I do this for subquestions?

Attachments:
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 8 months ago - 9 years 8 months ago #110614 by tpartner
Replied by tpartner on topic explanatory heading in array subquestion
Set up your survey to use JavaScript and add something like this to the source of the question:

Code:
<script type="text/javascript" charset="utf-8">  
  $(document).ready(function(){
 
    var newText = 'This is the sub-question header';
 
    $('#question{QID} table.subquestions-list thead td:first').addClass('sub-question-header').text(newText);
  });
</script>

Then you can style it with something like this at the end of template.css:

Code:
td.sub-question-header {
  font-size: 11px;
  padding: 4px 6px;
  color: red;
  text-align: right;
}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 9 years 8 months ago by tpartner.
The following user(s) said Thank You: szylkrecik
The topic has been locked.
More
4 years 5 months ago #189937 by ruthwiedemann
Replied by ruthwiedemann on topic explanatory heading in array subquestion
Hi there

I would like to do exactely that, adding an explanatory text before the subquestion, aligned to the left. I tried the code, however it doen't work. I work with the following version of LS: Version 3.15.9+190214.

I would really appreciate your help!
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 5 months ago #189946 by tpartner
Replied by tpartner on topic explanatory heading in array subquestion
This works in 3.19.1

Code:
<script type="text/javascript" charset="utf-8">  
  $(document).on('ready pjax:scriptcomplete',function(){
 
    var newText = 'This is the sub-question header';
 
    $('#question{QID} table.subquestion-list thead td:first').addClass('sub-question-header').text(newText);
  });
</script>



Sample survey attached:

File Attachment:

File Name: limesurvey...0-16.lss
File Size:20 KB

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
4 years 5 months ago #189947 by ruthwiedemann
Replied by ruthwiedemann on topic explanatory heading in array subquestion
This works like a charm! Thank you very much!
The topic has been locked.
More
4 years 5 months ago #189985 by ruthwiedemann
Replied by ruthwiedemann on topic explanatory heading in array subquestion
I have an additional question: how to you manipulate the color and the size of the explantory header? I've seen your previous comment, but I am totally new to this css/javascript stuff. Where do I actually add the indications about style, or asked differentely: wher is the end of template.css?
I added after your code that you send yesterday, but it doesn't work...
Thanks for your help!
The topic has been locked.
More
4 years 5 months ago #189989 by ruthwiedemann
Replied by ruthwiedemann on topic explanatory heading in array subquestion
And even another question: can I repeat the header? I have a question with a lot of subquestions and I can repeat the answer options via the settings in lime survey, but the explanatory header does not repeat itself...
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 5 months ago #189991 by tpartner
Replied by tpartner on topic explanatory heading in array subquestion
Sure, here you go:

Code:
<script type="text/javascript" charset="utf-8">  
  $(document).on('ready pjax:scriptcomplete',function(){
 
    var newText = 'This is the sub-question header';
 
    $('#question{QID} table.subquestion-list tr.ls-heading td:first-child').addClass('sub-question-header').text(newText);
  });
</script>



Sample survey attached:

File Attachment:

File Name: limesurvey...0-17.lss
File Size:24 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose