Welcome to the LimeSurvey Community Forum

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

explanatory heading in array subquestion

More
11 years 2 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?

The topic has been locked.
More
11 years 1 month ago - 11 years 1 month ago #110614 by tpartner
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: 11 years 1 month ago by tpartner.
The following user(s) said Thank You: szylkrecik
The topic has been locked.
More
5 years 10 months ago #189937 by ruthwiedemann
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.
More
5 years 10 months ago #189946 by tpartner
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:19.54 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
5 years 10 months ago #189947 by ruthwiedemann
This works like a charm! Thank you very much!
The topic has been locked.
More
5 years 10 months ago #189985 by ruthwiedemann
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
5 years 10 months ago #189989 by ruthwiedemann
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.
More
5 years 10 months ago #189991 by tpartner
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.18 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.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose