Check out the LimeSurvey source code on GitHub!

question and rankind in one row

More
6 years 2 weeks ago #56301 by arconet
Is it possible to make a question containing a text field and ranking array in one row-
example: Which cars do you have, rank 1 to 5 balls

field1 1 2 3 4 5
field2 1 2 3 4 5
field3 1 2 3 4 5

Please Log in to join the conversation.

More
6 years 2 weeks ago #56302 by arconet
Sorry for the trouble, I almoust found it here, www.limesurvey.org/en/forum/design-issue...iy?limit=10&start=10 , but I'm not sure
how can I insert the javascript to the question source.

Please Log in to join the conversation.

More
6 years 2 weeks ago #56321 by tpartner

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
6 years 2 weeks ago #56434 by arconet
It seems I'm still doing something wrong ..
I created a text question (id 3) and then an array quiesion (k31), after that inserted the javascript:

<script type="text/javascript" charset="utf-8">

$(document).ready(function() {

var qText = 3;
var qArray = K31;

// Fix the width of the survey
$( 'table.outerframe' ).css({'width': '900px'});

// Wrap the 2 questions ina container div and style it
$('#question'+qText+', #question'+qArray+'').wrapAll('<div class="inlineWrapper" />');
$('.inlineWrapper').append('<div style="clear:both" />');
$('.inlineWrapper').css({
'width': '75%',
'margin':'0 auto 10px auto',
'background-color':'#FFFFFF'
});
$('.inlineWrapper *').css({
'padding': '0',
'margin':'0'
});

// Hide the question and the help text
$('#question'+qText+' td.questiontext, #question'+qArray+' td.questiontext').parent().hide();
$('#question'+qText+' > table:eq(1), #question'+qArray+' > table:eq(1)').hide();
$('#question'+qText+' td.survey-question-help, #question'+qArray+' td.survey-question-help').parent().hide();

//Hide the answer cell of the array
$('#question'+qArray+' table.question thead tr').children(":first").hide();
$('#question'+qArray+' table.question tbody tr').children(":first").hide();
$('#question'+qArray+' col').attr('width', '');

// Push all question tables to 100%
$('#question'+qText+' table, #question'+qArray+' table').css({'width': '100%'});

// Get the 2 questions to sit politely side by side
$('#question'+qText+', #question'+qArray+'').css({'float':'left'});
$('#question'+qText+'').css({'padding':'15px 0 5px 25px'});
$('#question'+qText+'').css({'padding-top':'27px'}); // Adjust here for wrapped array labels
$('#question'+qArray+'').css({'padding':'5px 0 10px 0'});
$('#question'+qArray+' table.question td').css({'padding':'4px'});
$('#question'+qText+' table:first').attr('align', 'left');
$('#question'+qText+' label').css({
'display':'inline',
'width':'auto',
'margin-right':'10px'
});

// Set the widths of the 2 questions
$('#question'+qText+'').css({'width': '35%'});
$('#question'+qArray+'').css({'width': '58%'});

});

</script>

The problem is, at the preview I still only see my text questions:
www.arconet.ee/limesurvey/admin/admin.ph...ion&sid=89746&qid=97

Please Log in to join the conversation.

More
6 years 2 weeks ago #56437 by tpartner
Are you sure you used the correct IDs?



Cheers,
Tony Partner

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

Please Log in to join the conversation.

More
6 years 2 weeks ago #56442 by arconet
Well, that was one of the problems :)
but it still doesnt do what I want to it to do..
Would you mind having a look at my site? I can make a donation to limesurvey or yourself for the effort..

Please Log in to join the conversation.

More
6 years 2 weeks ago #56448 by tpartner
That link is to a question preview and doesn't work without logging in.

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
6 years 2 weeks ago - 6 years 2 weeks ago #56517 by tpartner
Okay. I've had a look and tweaked your survey. I think you were using the wrong question types (and script) for your purposes.

I used an array-text question followed by a plain array question.

The array-text question has one column (x-scale subquestion) with no question text and 4 rows (y-scale subquestions). The array question has the same rows as the first question and uses a label-set 1-5.

Then I added the following code to the source of the first question (replace "11" with the array-text ID and "22" with the array ID).

The script wraps the 2 questions in a division, places them side-by-side and hides some unecessary elements.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
        // The question IDs
	var q1 = 11;       
        var q2 = 22;
 
        if ($('.inlineWrapper').length == 0) {
			// Fix the width of the survey
			$( 'table.outerframe' ).css({'width': '900px'});
 
			// Wrap the 2 questions ina container div and style it
			$('#question'+q1+', #question'+q2+'').wrapAll('<div class="inlineWrapper" />');
			$('.inlineWrapper').append('<div style="clear:both" />');
			$('.inlineWrapper').css({
				'width': '75%',
				'margin':'0 auto 10px auto',
				'background-color':'#FFFFFF'
			});
			$('.inlineWrapper *').css({
				'padding': '0',
				'margin':'0'
			});
 
			// Hide the question and the help text
			$('#question'+q1+' td.questiontext, #question'+q2+' td.questiontext').parent().hide();
			$('#question'+q1+' > table:eq(1), #question'+q2+' > table:eq(1)').hide();
			$('#question'+q1+' td.survey-question-help, #question'+q2+' td.survey-question-help').parent().hide();
 
			//Hide the answer cell of the array
			$('#question'+q2+' table.question thead tr').children(':first').hide();
			$('#question'+q2+' table.question tbody tr').children(':first').hide();
			$('#question'+q2+' table.question tbody tr').each(function(i) {
				$(this).children(':first').hide();
			});
			$('#question'+q2+' col').attr('width', '');
 
			// Push all question tables to 100%
			$('#question'+q1+' table, #question'+q2+' table').css({'width': '100%'});
 
			// Get the 2 questions to sit politely side by side
			$('#question'+q1+', #question'+q2+'').css({'float':'left'});
			$('#question'+q1+'').css({'padding':'5px 0 5px 25px'});
			$('#question'+q2+'').css({'padding':'5px 0 5px 0'});
			$('#question'+q1+' table.question tbody td, #question'+q2+' table.question tbody td').css({'height':'25px'});
 
			// Set the widths of the 2 questions
			$('#question'+q1+'').css({'width': '45%'});
			$('#question'+q2+'').css({'width': '48%'});
		}
 
    });
 
</script>



Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
Last Edit: 6 years 2 weeks ago by tpartner.

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form