- Posts: 55
- Thank you received: 1
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Different sufixes in multiple numeric input questions
- Vinicos
- Topic Author
- Offline
- Senior Member
Less
More
4 years 1 week ago #197121
by Vinicos
Different sufixes in multiple numeric input questions was created by Vinicos
Hello,
I want to use different sufixes in a multiple numeric input question.
I have found two syntaxes in previous topics from this forum:
First:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
var thisQuestion = $('#question{QID}');
$('input.text:eq(0)', thisQuestion).after('/day')
$('input.text:eq(1)', thisQuestion).after('/month')
$('input.text:eq(2)', thisQuestion).after('/year')
$('input.text:eq(3)', thisQuestion).after('/decade')
});
</script>
Second:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$('#question'+{QID}+' li.question-item:eq(0) span.input').append('per minute');
$('#question'+{QID}+' li.question-item:eq(1) span.input').append('per hour');
$('#question'+{QID}+' li.question-item:eq(2) span.input').append('per day');
});
</script>
I have been trying for days to use this syntaxes, but I failed. I might be doing something wrong, as I'm not good at all with javascript language. Can someone please tell me what exatcly I need to change in this syntaxes?
My question code is "ImmigrationTime", the subquestions code are "years" and "months", and the sufixes I want are "anos e" and "meses".
Thanks.
I want to use different sufixes in a multiple numeric input question.
I have found two syntaxes in previous topics from this forum:
First:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
var thisQuestion = $('#question{QID}');
$('input.text:eq(0)', thisQuestion).after('/day')
$('input.text:eq(1)', thisQuestion).after('/month')
$('input.text:eq(2)', thisQuestion).after('/year')
$('input.text:eq(3)', thisQuestion).after('/decade')
});
</script>
Second:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$('#question'+{QID}+' li.question-item:eq(0) span.input').append('per minute');
$('#question'+{QID}+' li.question-item:eq(1) span.input').append('per hour');
$('#question'+{QID}+' li.question-item:eq(2) span.input').append('per day');
});
</script>
I have been trying for days to use this syntaxes, but I failed. I might be doing something wrong, as I'm not good at all with javascript language. Can someone please tell me what exatcly I need to change in this syntaxes?
My question code is "ImmigrationTime", the subquestions code are "years" and "months", and the sufixes I want are "anos e" and "meses".
Thanks.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11661
- Thank you received: 2742
4 years 1 week ago #197128
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Different sufixes in multiple numeric input questions
Just like in the other post: you might be using code for older versions. The template system has changed quite a bit with each of the last major releases, so workarounds for older versions generally don't work with newer versions anymore.
So please post which version you are using.
So please post which version you are using.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- Vinicos
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 55
- Thank you received: 1
4 years 1 week ago #197136
by Vinicos
Replied by Vinicos on topic Different sufixes in multiple numeric input questions
Thanks, holch
As I mentioned in the other post, I'm using the version 3.17.7
As I mentioned in the other post, I'm using the version 3.17.7
The topic has been locked.
- Vinicos
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 55
- Thank you received: 1
4 years 1 week ago #197137
by Vinicos
Replied by Vinicos on topic Different sufixes in multiple numeric input questions
3.17.7+190627 ***
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12943
- Thank you received: 3979
4 years 1 week ago #197140
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Different sufixes in multiple numeric input questions
Hi,
if you ask for a date, your idea is the worst of all (in my opinion).
Why?
You have to validate both fields of the multiple numeric input, to avoid "1673" and "24" as month.
For a date you should either use a date question.
or you may use an array(numbers)
Here the dropdowns are restricted to your allowed values
or you may use a different datepicker (which I found, but won't recommend)
Here an example of all three options.
Joffm
if you ask for a date, your idea is the worst of all (in my opinion).
Why?
You have to validate both fields of the multiple numeric input, to avoid "1673" and "24" as month.
For a date you should either use a date question.
or you may use an array(numbers)
Here the dropdowns are restricted to your allowed values
or you may use a different datepicker (which I found, but won't recommend)
Here an example of all three options.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- Vinicos
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 55
- Thank you received: 1
4 years 1 week ago #197143
by Vinicos
Replied by Vinicos on topic Different sufixes in multiple numeric input questions
Thanks, Joffm,
But I'm actually asking the amount of time that the participant has spent living abroad:
"How long have you been living abroad?"
The answer would be two numeric inputs:
___ years and
___ months
I have already put validation subquestion equations for years (less than age) and also months (less than 12). I only need now the information I asked concerning how to use different sufixes.
Later on, I will make similar questions regarding the amount of time that the participant is in a relationship, etc.
A date question would also fit, but I prefer to ask for the amount of time, just like in other similar surveys I have myself participated.
Vini
But I'm actually asking the amount of time that the participant has spent living abroad:
"How long have you been living abroad?"
The answer would be two numeric inputs:
___ years and
___ months
I have already put validation subquestion equations for years (less than age) and also months (less than 12). I only need now the information I asked concerning how to use different sufixes.
Later on, I will make similar questions regarding the amount of time that the participant is in a relationship, etc.
A date question would also fit, but I prefer to ask for the amount of time, just like in other similar surveys I have myself participated.
Vini
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
4 years 1 week ago #197145
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 Different sufixes in multiple numeric input questions
Try this:
Code:
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:complete',function() { // Identify this question var thisQuestion = $('#question{QID}'); $('input:text:eq(0)', thisQuestion).after('per minute'); $('input:text:eq(1)', thisQuestion).after('per hour'); $('input:text:eq(2)', thisQuestion).after('per day'); $('input:text', thisQuestion).css({ 'display': 'inline-block', 'margin-right': '0.5em' }); }); </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.
- Vinicos
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 55
- Thank you received: 1
4 years 1 week ago #197149
by Vinicos
Replied by Vinicos on topic Different sufixes in multiple numeric input questions
I tried, but it didn't work.
I'm not sure if I did it right:
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:complete',function() {
// Identify this question
var thisQuestion = $('#question{ImmigrationTime}');
$('input:text:eq(years)', thisQuestion).after('anos e');
$('input:text:eq(months)', thisQuestion).after('meses');
$('input:text', thisQuestion).css({
'display': 'inline-block',
'margin-right': '0.5em'
});
});
</script>
Question code: ImmigrationTime
subquestions code: "years" and "months"
sufixes: "anos e" and "meses"
I'm not sure if I did it right:
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:complete',function() {
// Identify this question
var thisQuestion = $('#question{ImmigrationTime}');
$('input:text:eq(years)', thisQuestion).after('anos e');
$('input:text:eq(months)', thisQuestion).after('meses');
$('input:text', thisQuestion).css({
'display': 'inline-block',
'margin-right': '0.5em'
});
});
</script>
Question code: ImmigrationTime
subquestions code: "years" and "months"
sufixes: "anos e" and "meses"
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
4 years 1 week ago #197153
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 Different sufixes in multiple numeric input questions
Do not change the ExpressionScript tag or the selector indexes
Code:
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:complete',function() { // Identify this question var thisQuestion = $('#question{QID}'); $('input:text:eq(0)', thisQuestion).after('anos e'); $('input:text:eq(1)', thisQuestion).after('meses'); $('input:text', thisQuestion).css({ 'display': 'inline-block', 'margin-right': '0.5em' }); }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: holch
The topic has been locked.
- Vinicos
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 55
- Thank you received: 1
4 years 1 week ago #197155
by Vinicos
Replied by Vinicos on topic Different sufixes in multiple numeric input questions
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
4 years 1 week ago #197156
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 Different sufixes in multiple numeric input questions
Please refer to the manual - Label column width -
manual.limesurvey.org/Question_type_-_Mu...abel_column_width.29
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- Vinicos
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 55
- Thank you received: 1
4 years 1 week ago #197158
by Vinicos
Replied by Vinicos on topic Different sufixes in multiple numeric input questions
Thanks, tpartner!
It's just perfect now.
It's just perfect now.
The topic has been locked.