Three part question

More
2 months 2 weeks ago #171941 by jimdavies
jimdavies created the topic: Three part question
Is it possible to ask for three values in one question? Screen shot shows what I envision.
First participant selects the quarter then they select the year then they enter the value for that quarter/year and do that for three time periods.
Attachments:

Please Log in or Create an account to join the conversation.

More
2 months 6 days ago #172243 by lemonlimebitters
lemonlimebitters replied the topic: Three part question

lemonlimebitters

Please Log in or Create an account to join the conversation.

More
2 months 5 days ago - 2 months 5 days ago #172246 by Joffm
Joffm replied the topic: Three part question
Hi,
for the 2.50/2.73 branch there is a workaround:



Will it be necessary to calculate the last three quarters. I mean, if we are in april 2018, the last there are:
Q1/2018, Q4/2017, Q3/2017?
Or is it sufficient to say: "last three"?

Example:

File Attachment:

File Name: limesurvey...8728.lss
File Size:31 KB


Here the script: (of course tpartner created it)
Consider the remark at the end - styling LS 2.67
<script type="text/javascript" charset="utf-8">
	$(document).ready(function(){	
 
		// Identify this question
		var qID = {QID};
		var thisQuestion = $('#question'+qID);
 
		// Add some classes
		$(thisQuestion).addClass('with-exclusive-items');
		$('td.answer-item', thisQuestion).addClass('non-exclusive-item');
 
		// Loop through the last-column cells
		$('td.answer-item:last-child', thisQuestion).each(function(i) {
			varThisID = $('input[type="text"]', this).attr('id');
 
			// Add a class
			$(this).removeClass('non-exclusive-item').addClass('exclusive-item');
 
			// Hide the text input
			$('td.answer-item:last-child input[type="text"]', thisQuestion).hide();
 
			// Insert checkboxes
			$(this).append('<div class="checkbox">\
								<input class="checkbox" name="" id="'+varThisID+'_cbox" value="N/A" type="checkbox">\
								<label for="'+varThisID+'_cbox" class="answertext inserted-label"></label>\
							</div>'); 
		});
 
		// Listener on the checkboxes
		$('.exclusive-item input[type="checkbox"]', thisQuestion).on('change', function(e) {
			var thisRow = $(this).closest('tr.subquestion-list');
			var thisCell = $(this).closest('td.answer-item');
			if($(this).is(':checked')) {
				$('input[type="text"]', thisCell).val('1');
				$('.non-exclusive-item input[type="text"]', thisRow).val('');
			}
			else {
				$('input[type="text"]', thisCell).val('');
			}
 
			// Fire Expression Manager
			$('input[type="text"]', thisRow).each(function(i) {
				$(this).trigger('keyup');
			});
		});
 
		// Listener on the text inputs
		$('.non-exclusive-item input[type="text"]', thisQuestion).on('keyup change', function(e) {
			var thisRow = $(this).closest('tr.subquestion-list');
			if($.trim($(this).val()) != '') {
				$('.exclusive-item input[type="checkbox"]', thisRow).prop('checked',false);
				$('.exclusive-item input[type="text"]', thisRow).val('');
			}
 
			// Fire Expression Manager
			$('.exclusive-item input[type="text"]', thisRow).trigger('keyup');
		});
 
		// Insert some styles (these could be in template.css)
		// For the LS 2.67 default template
		var newStyles = '.with-exclusive-items thead th.answertext {\
							text-align: center;\
						}\
						.with-exclusive-items .exclusive-item {\
							text-align: center;\
							vertical-align: middle;\
							cursor: pointer;\
						}\
						.with-exclusive-items .checkbox {\
							padding-left: 0;\
						}\
						.with-exclusive-items .inserted-label {\
							width: 24px;\
							min-height: 24px;\
							padding: 0;\
						}\
						.with-exclusive-items .inserted-label::before {\
							margin: 4px 0 0 4px;\
						}\
						.with-exclusive-items .inserted-label::after {\
							margin: 4px 0 0 4px;\
						}';	
		$('head').append('<style type="text/css">'+newStyles+'</style>');	
	});	
</script>



Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
Last Edit: 2 months 5 days ago by Joffm.

Please Log in or Create an account to join the conversation.

More
2 months 5 days ago - 2 months 5 days ago #172249 by LouisGac
LouisGac replied the topic: Three part question
I recently created a survey theme to be able to create those kind of arrays. It will be available on premium themes when it will be deeply tested. You'll find it attached to this post. I've also attached a Demo survey using it.

The idea is this one:

just add "row_1" in the class of the questions you want in the first row of the array, row_2 for the second row, etc
feel free to ask for more questions here.

here an online demonstration for it:
louissseb.limequery.com/672747?newtest=Y&lang=en

(note that any theme extending vanilla can extend mixed_array )

here the same survey with vanilla theme, so you can see the real structure of the survey:

louissseb.limequery.com/894297?lang=en
Attachments:
Last Edit: 2 months 5 days ago by LouisGac.

Please Log in or Create an account to join the conversation.

More
2 months 5 days ago #172259 by tpartner
tpartner replied the topic: Three part question
Here is a post showing how to insert drop-downs into an array-texts type question - www.limesurvey.org/forum/can-i-do-this-w...dropdown-list#169344


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

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!