Multiple numeric

More
3 years 1 month ago #113420 by guyllaume
guyllaume created the topic: Multiple numeric
Hi,

I want to know if it's possible to assign a different min and max value for each of the numeric entry in multiple numeric entry question ?

Many thanks in advance

Please Log in to join the conversation.

More
3 years 1 month ago #113423 by holch
holch replied the topic: Multiple numeric
Not by default. You might be able to do something with Javascript, maybe.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds
The following user(s) said Thank You: guyllaume

Please Log in to join the conversation.

More
3 years 1 month ago #113429 by tpartner
tpartner replied the topic: Multiple numeric
You could do it with JavaScript but it would be far easier to create several questions and use CSS to make them appear as one.


.

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

Please Log in to join the conversation.

More
3 years 1 month ago #113451 by guyllaume
guyllaume replied the topic: Multiple numeric
I did not think css. But if I use several questions, I can no longer use the Sum.
And about javascript, i do not know very well (as my English).

Thank's for your help.

Please Log in to join the conversation.

More
3 years 1 month ago - 3 years 1 month ago #113493 by tpartner
tpartner replied the topic: Multiple numeric
Ah, if you need to use the sum feature, several questions may not be appropriate.

Regarding the JavaScript...

For example, if you have a 4-option question where you want the minimums to be "5, 5, 20, 30" and the maximums to be "50, 50, 70, 100", you could:

1) Set up your survey to use JavaScript .

2) Insert something like this script in the question source. It will add a "max-min-error" class to any input that is out of its allowed max/min values and prevent the survey from advancing until the values are fixed.
<script type="text/javascript" charset="utf-8">	
	$(document).ready(function(){
 
		// The variables
		var minimums = [5, 5, 20, 30];
		var maximums = [50, 50, 70, 100];
		var errorAlert = 'One or more of the inputs is out of its allowed range. Please re-enter the values';
 
		// Identify this question		
		var thisQuestion = $('#question{QID}');
 
		// Add some attributes to the numeric inputs
		$('input.text', thisQuestion).each(function(i) {
			$(this).attr('data-min', minimums[i]);
			$(this).attr('data-max', maximums[i]);
		});
 
		// Listeners on the numeric inputs
		$('input.text', thisQuestion).bind('keyup change', function(event) {
			if($(this).val() < Number($(this).attr('data-min')) || $(this).val() > Number($(this).attr('data-max'))) {
				$(this).closest('li.question-item').addClass('max-min-error');
			}
			else {
				$(this).closest('li.question-item').removeClass('max-min-error');
			}
		});
 
		// Interrupt the Next/Submit function (to test for max/min errors)
		$('#movenextbtn, #movesubmitbtn').bind('click', function () {			
			if($('li.max-min-error', thisQuestion).length > 0) {
				alert(errorAlert);
				return false;
			}
		});
	});
</script>

3) Add something like this to the end of template.css:
.max-min-error input {
	background: pink;
	border: 1px solid red;
}

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 3 years 1 month ago by tpartner.
The following user(s) said Thank You: guyllaume

Please Log in to join the conversation.

More
3 years 1 month ago #113495 by guyllaume
guyllaume replied the topic: Multiple numeric
I'll test your solution next monday.
Thank's a lot, Tpartner, for your help and yours explanations.

Guyllaume

Please Log in to join the conversation.

More
3 years 1 month ago #113503 by DenisChenu
DenisChenu replied the topic: Multiple numeric

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 .
The following user(s) said Thank You: guyllaume

Please Log in to join the conversation.

More
3 years 1 month ago #113511 by guyllaume
guyllaume replied the topic: Multiple numeric
Yes indeed.
It will be a good solution, and simpler than javascript.

Thank you.

Please Log in to join the conversation.

More
3 years 1 month ago #113730 by guyllaume
guyllaume replied the topic: Multiple numeric
I have tested your solution, and it's perfect.

Thank's a lot Tpartner.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!