Welcome to the LimeSurvey Community Forum

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

Array Subheadings

  • stephanieteresa93
  • stephanieteresa93's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 1 month ago #194703 by stephanieteresa93
Array Subheadings was created by stephanieteresa93
Hi,

I am having some issues with a script code I copied from another post to add subheadings to array.

This is the code i used:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {

// Identify this question
var thisQuestion = $('#question{QID}');

// Define the sub-heading text strings
var subHeading1 = 'Subheading 1';
var subHeading2 = 'Subheading 2';

var columnsLength = $('tr.answers-list:eq(0) > *', thisQuestion).length;

// Insert the new rows
$('tr.answers-list:eq(0)', thisQuestion).before('<tr class="sub-header-row"><th colspan="'+columnsLength+'">'+subHeading1+'</th></tr>');
$('tr.answers-list:eq(2)', thisQuestion).before('<tr class="sub-header-row"><th colspan="'+columnsLength+'">'+subHeading2+'</th></tr>');

// Fix up the row classes
var rowClass = 1;
$('table.subquestions-list tbody tr', thisQuestion).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>

But if you see the screenshot attached under subheading 2 is one answer option when it should be all 3 answer options under each subheading.

Does anyone know how I can fix this?

Thank you so much in advance,

Stephanie
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago - 4 years 1 month ago #194705 by holch
Replied by holch on topic Array Subheadings
The question you are using is a "array by column" question type?

Ideally you always provide a LSS file with only the relevant parts. This way we can import what you are trying to do and play around and see where the problems are.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Last edit: 4 years 1 month ago by holch.
The topic has been locked.
  • stephanieteresa93
  • stephanieteresa93's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 1 month ago #194708 by stephanieteresa93
Replied by stephanieteresa93 on topic Array Subheadings
It is just "Array", I have exported the file and attached here. Sorry for the crosspost earlier, I tried to delete it.

Please let me know if the attachment works

Stephanie
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago #194711 by holch
Replied by holch on topic Array Subheadings
Really? A "Array"? That doesn't make any sense, because you could choose for "Twin 1" both, "yes" as well as "no"...

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago #194713 by holch
Replied by holch on topic Array Subheadings
Please provide a LSS file (LimeSurvey Survey), not a LSQ (LimeSurvey Question). It helps us to not have to create a survey and a group to later import the question into this survey. And: your settings might be different to our settings, which could cause the problem.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • stephanieteresa93
  • stephanieteresa93's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 1 month ago #194717 by stephanieteresa93
Replied by stephanieteresa93 on topic Array Subheadings
Hi,

Here is .lss, it is Q5 I am having the issue with Q5.

Thanks
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago - 4 years 1 month ago #194719 by Joffm
Replied by Joffm on topic Array Subheadings
Hi,
what I see, is exactly what the script is thought for.


And the new rows are inserted before the first row and before the third row.
// Insert the new rows
$('tr.answers-list:eq(0)', thisQuestion).before('<tr class="sub-header-row"><th colspan="'+columnsLength+'">'+subHeading1+'</th></tr>');
$('tr.answers-list:eq(2)', thisQuestion).before('<tr class="sub-header-row"><th colspan="'+columnsLength+'">'+subHeading2+'</th></tr>');

Maybe your intention of inserting headers is different.

On the other side I have not the least idea how this question is to answer.
Why can't both twins have the answer "Yes", resp. both "No"?

You should really revise the design.
Most of your questions should be swapped (your intention is an array(columns) instead array.
holch mentioned that before.
Now you never are able to give the same answer for both twins, e.g. Q6 "Cows milk".
Twin 1 can answer "Yes" and "No", but not both can answer "Yes".


And I see in Q3 (and other places):
Yes (Goto Q5)
No (Goto Q7
Refused (Goto Q9)
Please read the manual about relevance equations.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 years 1 month ago by Joffm.
The topic has been locked.
  • stephanieteresa93
  • stephanieteresa93's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 1 month ago #194721 by stephanieteresa93
Replied by stephanieteresa93 on topic Array Subheadings
Okay thank you, I had no idea it was the wrong way, I will fix that (re. array column)!

Mostly my intention for this one was to have commercial milk? yes, no or refused for twin 1 and then answer yes, no or refused for twin 2. Then after whether or not iron was added: yes, no or refused for twin 1 and then twin 2.

Great, I will check out the relevance equation rules!

While checking my other questions, I was wondering, is it possible to have numerical input and radio buttons? You can probably see on some of them I ask them to answer Week, month or day that they enter numerically and then other options such as: "i still give them cow's milk" or "refused" would be nicer as radio buttons... is this a possibility on lime survey?

Thank you again, your help is very much appreciated since i am very new at this.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago #194723 by Joffm
Replied by Joffm on topic Array Subheadings
Hi,
I think you just copied a paper-pencil questionnaire.

But an online questionnaire is different.
Here you have all opportunities to lead the respondent through it, by routing, filtering, etc.

So I recommend:
Some of your "Yes/No" arrays are just multi punch questions where you check which one of the twins does, or both or none.

Don't mix "Yes/No" with answers, if "Yes" like Q5B, Q6B.

And your "month, week, day" questions with "DK":
How does a respondent fill the DK column?
How do you avoid that respondents enter "1 month", "4 weeks", "30 days". not realizing that only one field is to fill?
You have to validate that.
Better to have only one number field, folowed by a drop-down to enter the unit (month, week, day) and an exclusive checkbox for "DK".

Later I'll send some examples.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago #194728 by Joffm
Replied by Joffm on topic Array Subheadings
Hi,
here is a first example, how I could imagine to program your survey.

Only questions 1-5 and Q12, but the rest is more or less the repetition of these question types.
And consider: There is no validation on Q12,

Have a look.


Joffm

File Attachment:

File Name: limesurvey...2-29.lss
File Size:177 KB

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago - 4 years 1 month ago #194741 by Joffm
Replied by Joffm on topic Array Subheadings
Some addition:
This my example is to show you how to use
  • group relevance
  • question relevance
  • sub-question relevance
  • micro-tayloring (like {if(Q1==1,"Mr.","Mrs.")} )
to achieve a correct routing of your questionnaire.

Furthermore I think it a good idea to ask for the names of the children, and pipe these names into the following questions.
Just a question of type multiple short text (QName) with subquestions "name1" and "name2".
Then you can refer to the names in following questions by {QName_name1} resp. {QName_name2}

And here I show what these way to include sub headers was meant to.
To show a classification of the subquestions to the respondent to ease his life. (here with a little bit of css)


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 years 1 month ago by Joffm.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose