- Posts: 22
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Adding array header
- Gensz78
- Topic Author
- Offline
- Junior Member
Less
More
6 years 3 months ago #161913
by Gensz78
Adding array header was created by Gensz78
Hi!
I'd like to add a header on a array question, where answer options are on a 1-9 scale; a bit like the question asked here: www.limesurvey.org/forum/design-issues/9...-single-scale-matrix .
Ideally, there would be a "Low priority" header centered above answers 1-2-3, "Medium priority" above 4-5-6, and "High priority" above 7-8-9.
I've been trying to use this script (adapted from the solution in the linked post) without success (nothing happens):
Survey structure is attached. Please note that I use LimeSurvey Version 2.65.1+170522, with javascript enabled, and that I don't have access to the template.
Could anyone help me with this?
Thanks!
Gen
I'd like to add a header on a array question, where answer options are on a 1-9 scale; a bit like the question asked here: www.limesurvey.org/forum/design-issues/9...-single-scale-matrix .
Ideally, there would be a "Low priority" header centered above answers 1-2-3, "Medium priority" above 4-5-6, and "High priority" above 7-8-9.
I've been trying to use this script (adapted from the solution in the linked post) without success (nothing happens):
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Identify this question
var thisQuestion = $('#question{QID}');
// Insert a new row in the table head
$('table.subquestions-list thead', thisQuestion).prepend('<tr>\
<td></td>\
<th colspan="3">Low priority</th>\
<th colspan="3">Medium priority</th>\
<th colspan="3">High priority</th>\
</tr>');
});
</script>
Survey structure is attached. Please note that I use LimeSurvey Version 2.65.1+170522, with javascript enabled, and that I don't have access to the template.
Could anyone help me with this?
Thanks!
Gen
Attachments:
The topic has been locked.
- Gensz78
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 22
- Thank you received: 0
6 years 2 months ago #162293
by Gensz78
Replied by Gensz78 on topic Adding array header
Hi again! Could anyone help me with this? Thanks!
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
6 years 2 months ago #162295
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Adding array header
You were very close - you only had a small mistake in the jQuery selector for the table.
Try this, which also includes a class to center the text in the new cells.
Sample survey attached:
Try this, which also includes a class to center the text in the new cells.
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); // Insert a new row in the table head $('table.subquestion-list thead', thisQuestion).prepend('<tr>\ <td></td>\ <th colspan="3" class="text-center">Low priority</th>\ <th colspan="3" class="text-center">Medium priority</th>\ <th colspan="3" class="text-center">High priority</th>\ </tr>'); }); </script>
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The topic has been locked.
- Gensz78
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 22
- Thank you received: 0
6 years 2 months ago #162564
by Gensz78
Replied by Gensz78 on topic Adding array header
This is amazing! Thank you so much!
Gen
Gen
The topic has been locked.