- Posts: 2
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Two questions displaying as one
- GreavakeToora
- Topic Author
- Offline
- New Member
Less
More
10 years 9 months ago #96975
by GreavakeToora
Two questions displaying as one was created by GreavakeToora
A Limesurvey novice here, so please excuse if this is a really dumb question!
I need to display two questions as one. The first is a Multiple Numerical Input question with a slider, the second is a radio button list.
I'm using the basic template with v2.00 build 130526 and presenting the survey one question at a time.
I found the code below on these forums - it hides the second question and moves the radio buttons to the first question. This works well when you test the question group, but if you test the complete survey it still presents them one at a time (and I'm guessing that's how they'll get presented in the activated survey.)
What I ideally want is for both questions to be displayed on the same page, and a single submit button to return the answers for both questions at once. The questions are both mandatory btw, but the radio button question has code to default it to one particular answer.
Here's the code I was using - any help much appreciated!
$(document).ready(function(){
// Identify the questions
var thisQuestion = $('#question{QID}');
var nextQuestion = $(thisQuestion).next('div[id^="question"]');
// Hide the next question
$(nextQuestion).hide();
// Move the radios from the next question
$('.answer .answer-item', thisQuestion).append($('ul.answers-list', nextQuestion));
// Some cleanup styles
$('.answer-item select, .answer-item ul, .answer-item li', thisQuestion).css({
'float': 'left'
});
$('.answer-item ul', thisQuestion).css({
'list-style': 'none',
'margin-left': '50px'
});
$('.answer-item li', thisQuestion).css({
'margin-right': '15px'
});
});
I need to display two questions as one. The first is a Multiple Numerical Input question with a slider, the second is a radio button list.
I'm using the basic template with v2.00 build 130526 and presenting the survey one question at a time.
I found the code below on these forums - it hides the second question and moves the radio buttons to the first question. This works well when you test the question group, but if you test the complete survey it still presents them one at a time (and I'm guessing that's how they'll get presented in the activated survey.)
What I ideally want is for both questions to be displayed on the same page, and a single submit button to return the answers for both questions at once. The questions are both mandatory btw, but the radio button question has code to default it to one particular answer.
Here's the code I was using - any help much appreciated!
$(document).ready(function(){
// Identify the questions
var thisQuestion = $('#question{QID}');
var nextQuestion = $(thisQuestion).next('div[id^="question"]');
// Hide the next question
$(nextQuestion).hide();
// Move the radios from the next question
$('.answer .answer-item', thisQuestion).append($('ul.answers-list', nextQuestion));
// Some cleanup styles
$('.answer-item select, .answer-item ul, .answer-item li', thisQuestion).css({
'float': 'left'
});
$('.answer-item ul', thisQuestion).css({
'list-style': 'none',
'margin-left': '50px'
});
$('.answer-item li', thisQuestion).css({
'margin-right': '15px'
});
});
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10613
- Thank you received: 3691
10 years 9 months ago #97090
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 Two questions displaying as one
You will need to place both questions in the same group and display the survey in group-by-group mode. JavaScript can only manipulate questions on the same page.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- GreavakeToora
- Topic Author
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 0
10 years 8 months ago #97263
by GreavakeToora
Replied by GreavakeToora on topic Two questions displaying as one
Thanks Tony - the help is much appreciated!
The topic has been locked.