Array Question with "Other" Answer

Mehr
3 Jahre 7 Monate her #107415 von jajas
jajas erstellte das Thema Array Question with "Other" Answer
Dear LS Team,

I have matrix question and in LS i choose Array Question Type.
but in this question i need add "Other" Option for sub question.

HOw to add "Other" Option to array (matrix) question type?

Regards,

JajaS

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 7 Monate her #107418 von DenisChenu
DenisChenu antwortete auf das Thema: Array Question with "Other" Answer
Hi,

You can add a sub question, code OTHE (for example), if you need other comment :adding a question text with condition !is_empty(QQ_OTHE)

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 7 Monate her #107422 von jajas
jajas antwortete auf das Thema: Array Question with "Other" Answer
Hi Denis,

i'm not clear with your explanation.
can you give me an example for this case, please

Jajas

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 7 Monate her - 3 Jahre 7 Monate her #107427 von tpartner
tpartner antwortete auf das Thema: Array Question with "Other" Answer
You can add a multiple-short-text question after the array and use JavaScript to move the text inputs into the array.

Here is a similar solution - www.limesurvey.org/en/forum/design-issue...to-text-input#102550 .


.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Letzte Änderung: 3 Jahre 7 Monate her von tpartner.

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 7 Monate her #107571 von AdamDesrosiers
AdamDesrosiers antwortete auf das Thema: Array Question with "Other" Answer
I need to understand this as well. Been poking around these forums and there's too much assumed about one's coding ability. Please answer as if to a simpleton.

In any case, you link to a different kind of answer. The example in your link is to add text input fields into the answer fields of an array.

The OP in this thread, and myself, don't want to do anything fancy to the answer fields, just add one more subquestion to the array of "other" with an input ... the answers remain the same.

So for instance, how do you feel about the following bands/musicians?

Anhang:

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 7 Monate her #107603 von first
first antwortete auf das Thema: Array Question with "Other" Answer
I can do it for you if you can give me link to the page. Please note that survey should have group by group display so that I can add an additional hidden short free text question below your array type question.

Survey Designer and Programmer

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 6 Monate her #107719 von tpartner
tpartner antwortete auf das Thema: Array Question with "Other" Answer
Here is a small script that when placed in the source of an array question will:

1) Identify and hide a following short-text question
2) Move the text input from that hidden question into the last subquestion of the array as depicted above

<script type="text/javascript" charset="utf-8">	
 
	$(document).ready(function() {
 
		// Identify the questions
		var q1 = $('#question'+{QID}+'');
		var q2 = $(q1).nextAll('.text-short:eq(0)');
 
		// Hide the short-text question
		$(q2).hide();
 
		// Move the hidden text input into the array
		$('th.answertext:last', q1).append($('input[type="text"]', q2));
 
		// Some styling...
		$('input[type="text"]', q1).css({
			'width': '50%'
		});
	});
</script>

Here's a working sample for 2.05:

Dateianhang:

Dateiname: limesurvey...3296.lss
Dateigröße:17 KB

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Anhang:

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 6 Monate her #107747 von first
first antwortete auf das Thema: Array Question with "Other" Answer
@tpartner : You write very nice generic jquery :). I have a suggestion in your code. Please append an error below below question text and do not let user to continue (return false on submit) if user try to pass question leaving textbox empty and choosing a radio button in the same row or vice versa.

Survey Designer and Programmer

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 6 Monate her #107748 von first
first antwortete auf das Thema: Array Question with "Other" Answer
and the code should be placed in workarounds because having an other specify in array questions in very common requirement.

Survey Designer and Programmer

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 6 Monate her - 3 Jahre 6 Monate her #107751 von tpartner
tpartner antwortete auf das Thema: Array Question with "Other" Answer
Hi Trivender, thanks for the suggestion. I thought of that but there are a couple of behaviour issues to be considered...

1) What if the respondent changes their mind about "Other". There is no way to deselect a radio. I suppose we could put a listener on the text input to deselect all radios in that row if a keyup event detects no value in the text input but that's not entirely intuitive. Maybe a "Clear" button?.

2) How to handle mandatory questions? Maybe a hidden "N/A" column?

Your thoughts?

.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Letzte Änderung: 3 Jahre 6 Monate her von tpartner.

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 6 Monate her #107753 von first
first antwortete auf das Thema: Array Question with "Other" Answer
I tried to write a little jquery code showing my thoughts . Please suggest how it looks.
<script>
$(document).ready(function(){
$('button#movesubmitbtn').on('click',function(){
var $otherRow = $('div.array-flexible-row table.subquestions-list tr:has("input:text")');
for(var i=0;i<$otherRow.length;i++){
var checkedRadio = $otherRow.eq(i).find('td:not("td.noanswer-item")').find('input:checked').length;
var boxVal = $.trim($otherRow.eq(i).find('input:text').val());
if(((checkedRadio != 0) && (boxVal == "")) || ((checkedRadio == 0) && (boxVal != ""))){
alert('Please review your answer in other specify row.');
return false;
}
break;
}
});
//clear other specify value on click of no answer
$('td.noanswer-item').on('click',function(){
$(this).parent().find('input:text').val('');
});
//uncheck no answer on keydown inside otherspecify box.
$('div.array-flexible-row table.subquestions-list input:text').on('keydown',function(){
$(this).parent().parent().find('td.noanswer-item input:radio').prop('checked',false);
});
});
</script>

Survey Designer and Programmer

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 6 Monate her #107792 von tpartner
tpartner antwortete auf das Thema: Array Question with "Other" Answer
Okay, using the "No Answer" survey setting simplifies things a bit and to expand a little on your line of thinking...
  1. Add a class to the "Other" row for styling and manipulation
  2. Use question-specific selectors
  3. Use keyup and change events to on the text inputs (in case someone pastes)
  4. Prevent the click event on the submit button from firing more than once if there are multiple instances of these questions
<script type="text/javascript" charset="utf-8">	
 
	$(document).ready(function() {
 
		// Identify the questions
		var thisQuestion = $('#question'+{QID}+'');
		var nextQuestion = $(thisQuestion).nextAll('.text-short:eq(0)');
 
		// Hide the short-text question
		$(nextQuestion).hide();
 
		// Move the hidden text input into the array
		$('th.answertext:last', thisQuestion).append($('input[type="text"]', nextQuestion)).closest('tr').addClass('otherRow');
 
		// Some styling...
		$('input[type="text"]', thisQuestion).css({
			'width': '50%'
		});		
 
		// Handle the "Other" radios
		$('input[type="text"]', thisQuestion).on('keyup change',function(event){
			event.stopPropagation();
 
			if($.trim($(this).val()) == '') {
				$('.otherRow input:radio[value!=""]', thisQuestion).prop('checked',false);
				$('.otherRow input:radio[value=""]', thisQuestion).click();
			}
			else {
				$('.otherRow input:radio[value=""]', thisQuestion).prop('checked',false);
			}
		});	
 
		// Handle the "Other" text input
		$('.otherRow input.radio', thisQuestion).on('click',function(event){
			if($(this).attr('value') == '') {
				$('.otherRow input[type="text"]', thisQuestion).val('');
			}
		});
 
		// Validate the "Other" text input(s) on submit
		if($('#movenextbtn, #movesubmitbtn').attr('data-inserted-other') != 'true') { // We're only doing this once on this page
			$('#movenextbtn, #movesubmitbtn').attr('data-inserted-other', 'true').on('click.insertedOther', function (event) {
 
				var otherError = 0;
 
				$('.array-flexible-row .otherRow').each(function(i) {
 
					if(($('input:radio[value!=""]:checked', this).length > 0 && $('input[type="text"]', this).val() == '') || ($('input:radio[value!=""]:checked', this).length == 0 && $('input[type="text"]', this).val() != '')) {
						otherError = 1;
					}
				});
 
				if(otherError == 1) {
					alert('Please review your answer in the "Other" row(s).');
					return false;
				}
			});
		}
	});
</script>


Dateianhang:

Dateiname: limesurvey...9779.lss
Dateigröße:26 KB

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Anhang:
Folgende Benutzer bedankten sich: jake1729

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 6 Monate her #107841 von jajas
jajas antwortete auf das Thema: Array Question with "Other" Answer
Dear LS Team,

To make it simple, how about make enhancement in limesurvey,
for array question add Option for Other answer like single or multiple question type?

i believe LS team can do that.

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 6 Monate her #107844 von jajas
jajas antwortete auf das Thema: Array Question with "Other" Answer
How about array question like attached image.

any idea?

Need suggestion please...
Anhang:

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
3 Jahre 6 Monate her - 3 Jahre 6 Monate her #107848 von tpartner
tpartner antwortete auf das Thema: Array Question with "Other" Answer

To make it simple, how about make enhancement in limesurvey,
for array question add Option for Other answer like single or multiple question type?

You can submit a feature request - www.limesurvey.org/en/community-services/feature-requests .


How about array question like attached image.

I think you have enough information in this thread to accomplish that.


.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Letzte Änderung: 3 Jahre 6 Monate her von tpartner.

Bitte Anmelden um an der Konversation teilzunehmen.

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten

Abonnieren Sie unseren Newsletter

Abonnieren Sie unseren Newsletter für alle Neuigkeiten rund um LimeSurvey
captcha