Multiple short text: post-text for every subquestion

More
1 month 3 weeks ago #158068 by Jmantysalo
Jmantysalo created the topic: Multiple short text: post-text for every subquestion
Is it possible to make an array of text inputs like

I jump in a trampoline
1. about ___ times a day
2. about ___ times per week
3. about ___ times in a year

? I found manual.limesurvey.org/Workarounds:_Quest..._.22question_code.22 but there is not question.pstpl in newer version of LimeSurvey.

Please Log in to join the conversation.

More
1 month 3 weeks ago - 1 month 3 weeks ago #158099 by tpartner
tpartner replied the topic: Multiple short text: post-text for every subquestion
The question.pstpl file does exist in the new versions of LimeSurvey and will through the LS 3.x series but I don't think you need to modify it for this layout.

1) Enter your prefixes and suffixes in the sub-question text, separated by commas as in the first screenshot below.

2) Set up your survey to use JavaScript and place the following script in the source of the question:

<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		// Identify this question
		var thisQuestion = $('#question{QID}');
 
		// Insert the modified labels
		$('.control-label', thisQuestion).each(function(i) {
			var thisRow = $(this).closest('.answer-item');
			var labels = $(this).text().split(',')
			$('input.text', thisRow).before('<span class="inserted-prefix">'+$.trim(labels[0])+'</span>');
			$('input.text', thisRow).after('<span class="inserted-suffix">'+$.trim(labels[1])+'</span>');
		});
 
		// Some cleanup styling
		$('.control-label', thisQuestion).css({
			'display': 'none'
		});
		$('.form-group.row > div', thisQuestion).css({
			'float': 'none',
			'width': 'auto'
		});
		$('input.text', thisQuestion).css({
			'display': 'inline-block',
			'margin': '0 15px',
			'width': '75px'
		});
	});
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey...8-29.lss
File Size:16 KB





Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
Last Edit: 1 month 3 weeks ago by tpartner.

Please Log in to join the conversation.

More
1 month 3 weeks ago #158101 by Jmantysalo
Jmantysalo replied the topic: Multiple short text: post-text for every subquestion
Great! This works, many thanks.

Please Log in to join the conversation.

More
1 month 3 weeks ago #158123 by DenisChenu
DenisChenu replied the topic: Multiple short text: post-text for every subquestion
Needed option in future : we have a lot of user asking it.

And we already have the option for numeric input ( using | as separator).

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 .

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now