Is it possible to make an array question that have for example 3 options for answers and 5 subquestions, but the last subquestion is empty (with word "other") that allows a users to input their own subquestion and then provide an answer from the given options?
Put this into your question text (source code mode)
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Identify the questions
var thisQuestion = $('#question'+{QID}+'');
var nextQuestion1 = $(thisQuestion).nextAll('.text-short:eq(0)');
var nextQuestions = $(nextQuestion1);
var nextLength = nextQuestions.length;
var sqLength = ('tr.answers-list', thisQuestion).length;
// Hide the short-text questions
$(nextQuestions).hide();
// Move the hidden text inputs into the array
for (i = 0; i < nextLength; i++) {
var workingIndex = (sqLength - 1) - (nextLength - i);
var nextQ = nextQuestions[i];
$('th.answertext:eq('+workingIndex+')', thisQuestion).append($('input[type="text"]', nextQ)).closest('tr').addClass('otherRow');
}
// Some styling...
$('input[type="text"]', thisQuestion).css({
'width': '100%'
});
});
</script>
I am trying to implement the same thing and new to LimeSurvey.
I copied the javascript code to my question in source code mode but unfortunately the "Other" option does not appear when viewing the question. Would you know what I am doing wrong?
First of all thanks to Joffm for the help on how to insert the "Other" option into an array.
I downloaded the file and implemented the workaround as explained.
Now the problem is that the "Other" option is set as mandatory and one cannot proceed without entering a value. What I want is to have it as optional while Subquestion 1-4 are mandatory. Is there a way to implement this? I'm not very familiar with Javascript...
Many thanks. The way worked, so that the Other option can now be left blank.
Nevertheless after turning the question non-mandatory the array now shows the "No answer" option which I would like to turn off. Is there another way to keep the question mandatory and simply turn the "Other" option optional?
The "Other No answer" option is a setting that your installation has. There are two places where you can change that:
- On a survey level in the general configurations of the survey (but only if your super-admin allows that in the settings for the installation)
- On an installation level
So you need to check how these settings are for your survey and/or the Limesurvey Installation.
Help us to help you!
Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
Last edit: 5 years 7 months ago by holch. Reason: I was talking about the "no answer" setting, not "other".
I wanted to include an "Other" textfield option to an array which I managed with Joffm's help through his Javascript code. Like all other questions in my survey I wanted this one to be mandatory, which entailed that the user couldn't leave the "Other" option blank without receiving an error message. I then turned the question non-mandatory and validated the entries as explained by Joffm.
Now what I would like to do instead, is turn the appended "Other" text field optional while all other subquestions remain mandatory. Is there a way to do this?
There is a setting in Limesurvey that forces the "no answer" option for non mandatory questions. You need to find that setting and adapt it accordingly.
So just switch "other" with "no answer", the rest of the explanation is correct.
Help us to help you!
Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.