- Posts: 3
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Array question with input question from the user.
- theannam
- Topic Author
- Offline
- New Member
Less
More
3 years 1 month ago #212810
by theannam
Array question with input question from the user. was created by theannam
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?
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12888
- Thank you received: 3965
3 years 1 month ago #212813
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Array question with input question from the user.
Yes, it is possible.
Put this into your question text (source code mode)
Joffm
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>
Code:
<style type="text/css">.ls-answers tbody .answertext { text-align: left; } </style>
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: theannam
The topic has been locked.
- Wilhageli_253594
- Offline
- Banned
Less
More
- Posts: 1
- Thank you received: 0
3 years 1 month ago #212853
by Wilhageli_253594
Replied by Wilhageli_253594 on topic Array question with input question from the user.
Hi everybody,
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?
Many thanks.
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?
Many thanks.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12888
- Thank you received: 3965
3 years 1 month ago #212854
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Array question with input question from the user.
No, you did not show us what you did exactly.
Did you import the sample survey?
There you see what is not explained in detail.
Joffm
Did you import the sample survey?
There you see what is not explained in detail.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- ulrich1975
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
3 years 1 month ago - 3 years 1 month ago #212949
by ulrich1975
Replied by ulrich1975 on topic Array question with input question from the user.
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...
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...
Last edit: 3 years 1 month ago by ulrich1975.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12888
- Thank you received: 3965
3 years 1 month ago #212952
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Array question with input question from the user.
Set the question to "not mandatory" and validate the entries.
Like
if(is_empty(Q1Other1),count(self.NAOK)==4,count(self.NAOK)==5)
Meaning: If there is no entry in the "Other" field the necessary, 4 rows have to be answered, otherwise 5.
Joffm
Like
if(is_empty(Q1Other1),count(self.NAOK)==4,count(self.NAOK)==5)
Meaning: If there is no entry in the "Other" field the necessary, 4 rows have to be answered, otherwise 5.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- ulrich1975
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
3 years 1 month ago #212954
by ulrich1975
Replied by ulrich1975 on topic Array question with input question from the user.
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?
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 topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11639
- Thank you received: 2737
3 years 1 month ago - 3 years 1 month ago #212956
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Array question with input question from the user.
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.
- 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.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Last edit: 3 years 1 month ago by holch. Reason: I was talking about the "no answer" setting, not "other".
The topic has been locked.
- ulrich1975
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
3 years 1 month ago - 3 years 1 month ago #212971
by ulrich1975
Replied by ulrich1975 on topic Array question with input question from the user.
Thanks for your answer Holch.
I'm not sure your answer fits my problem:
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?
Thanks.
I'm not sure your answer fits my problem:
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?
Thanks.
Last edit: 3 years 1 month ago by ulrich1975.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11639
- Thank you received: 2737
3 years 1 month ago - 3 years 1 month ago #212986
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Array question with input question from the user.
I meant to write "no answer" not "other", sorry.
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.
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.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Last edit: 3 years 1 month ago by holch.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11639
- Thank you received: 2737
3 years 1 month ago #212987
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Array question with input question from the user.
Here a screenshot how this looks on LS 4.x within a survey:
I couldn't find the global setting. Might not be there in LS 4.x anymore.
I couldn't find the global setting. Might not be there in LS 4.x anymore.
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11639
- Thank you received: 2737
3 years 1 month ago #212988
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Array question with input question from the user.
Found it. In LS 4.x it is not in "Global settings", but in "Global survey settings":
In LS 3.x you'll probably find it in "Global settings" > "Presenation". I don't have access to a LS 3.x right now.
In LS 3.x you'll probably find it in "Global settings" > "Presenation". I don't have access to a LS 3.x right now.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The following user(s) said Thank You: DenisChenu
The topic has been locked.