- Posts: 2
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Multiple textbox question with NA option
- kko
- Topic Author
- Offline
- New Member
Less
More
7 years 5 months ago #142975
by kko
Multiple textbox question with NA option was created by kko
Hi, I need to add a question to LimeSurvey that allows users to enter up to 5 responses.
Question example: please list some of the music bands that you enjoy.
So, I decided to use "Multiple Short Text" question type and it works great. I've added 5 options with the same label "Enter text"
But in my example I want to add a checkbox "NA" at the bottom if they do not want to type-in any answers.
I have a requirement to have at least one of the fields populated OR NA checkbox checked.
Example:
__________
__________
__________
__________
__________
[_] NA
I know that I can set Mandatory "No" but this is a specific requirement that I need to follow.
Thanks a lot!
Question example: please list some of the music bands that you enjoy.
So, I decided to use "Multiple Short Text" question type and it works great. I've added 5 options with the same label "Enter text"
But in my example I want to add a checkbox "NA" at the bottom if they do not want to type-in any answers.
I have a requirement to have at least one of the fields populated OR NA checkbox checked.
Example:
__________
__________
__________
__________
__________
[_] NA
I know that I can set Mandatory "No" but this is a specific requirement that I need to follow.
Thanks a lot!
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10612
- Thank you received: 3691
7 years 5 months ago - 7 years 5 months ago #142991
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 Multiple textbox question with NA option
The simplest solution would be to insert a preceding question "Do you have any bands to list?" and place corresponding conditions/relevance on the multiple-text question.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 7 years 5 months ago by tpartner.
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5070
- Thank you received: 1263
7 years 5 months ago #143003
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Multiple textbox question with NA option
Or placing a question with just one checkbox after your question.
If checkbox is checked the question above is hidden via relevance/condition "Only show if box is not checked".
I find Tpartner's solution more elegant, but sometimes it saves time to no have to ask another question with text.
To make two question look like one question it would be nice to have a feature which removes the space between two question.
"11773: Remove / Reduce space between two questions (when doing workarounds)"
bugs.limesurvey.org/view.php?id=11773
If checkbox is checked the question above is hidden via relevance/condition "Only show if box is not checked".
I find Tpartner's solution more elegant, but sometimes it saves time to no have to ask another question with text.
To make two question look like one question it would be nice to have a feature which removes the space between two question.
"11773: Remove / Reduce space between two questions (when doing workarounds)"
bugs.limesurvey.org/view.php?id=11773
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10612
- Thank you received: 3691
7 years 5 months ago #143004
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 Multiple textbox question with NA option
That could be done with a small jQuery plugin and a little CSS. What LS version and base template do you normally use?To make two question look like one question it would be nice to have a feature which removes the space between two question.
"11773: Remove / Reduce space between two questions (when doing workarounds)"
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5070
- Thank you received: 1263
7 years 5 months ago #143015
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Multiple textbox question with NA option
Personally I currently only use LS 2.06LTS with default template modified. Had the hope that after the html cleanup this feature request will be doable in LS 2.5 without too much hassle. But since you asked for template it seems to be depending on that choice too.tpartner wrote: That could be done with a small jQuery plugin and a little CSS. What LS version and base template do you normally use?
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10612
- Thank you received: 3691
7 years 5 months ago #143024
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 Multiple textbox question with NA option
1) Place this function in template.js, it will add classes to the questions to be aggregated so we can target them with CSS.
2) Place something like this in template.css (this is for the 2.06 default template):
3) Call the function in the source of the first question text like this:
Code:
// A function to add classes to "aggregated" questions function aggregateQuestions(q1ID) { $('#question'+q1ID).addClass('aggregated-1'); $('#question'+q1ID).nextAll('div[id^="question"]:eq(0)').addClass('aggregated-2'); }
2) Place something like this in template.css (this is for the 2.06 default template):
Code:
.aggregated-1 .question-wrapper { margin-bottom: 0; } .aggregated-1 .answer { padding-bottom: 0; } .aggregated-2 .answer { padding-top: 0; } .aggregated-2 .questiontext { display: none; }
3) Call the function in the source of the first question text like this:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { aggregateQuestions({QID}); }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5070
- Thank you received: 1263
7 years 5 months ago #143030
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Multiple textbox question with NA option
Thanks for the workaround. Will give it a try.
The feature request should be template agnostic which should be possible when doing it before rendering.
Or did I miss something important and the idea is silly?
The feature request should be template agnostic which should be possible when doing it before rendering.
Or did I miss something important and the idea is silly?
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10612
- Thank you received: 3691
7 years 5 months ago #143046
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 Multiple textbox question with NA option
I'm not sure the feature could be totally independent of templates as some CSS rules are required and those would necessarily be in the template.
Perhaps it would be as simple as allowing the assignment of specific class(es) to the questions. Similar to how Joomla allows a "Page Class" or "Module Class Suffix". Then you could target those classes as I have done in the workaround.
Perhaps it would be as simple as allowing the assignment of specific class(es) to the questions. Similar to how Joomla allows a "Page Class" or "Module Class Suffix". Then you could target those classes as I have done in the workaround.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.