Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:
  • Page:
  • 1
  • 2

TOPIC: Please Help, hidden question with answers

Please Help, hidden question with answers 3 years 6 months ago #91709

  • tpartner
  • tpartner's Avatar
  • Online
  • LimeSurvey Team
  • Posts: 6204
  • Thank you received: 1374
  • Karma: 538
This should work in "all-in-one" mode. Do you get any JavaScript errors?
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Please Help, hidden question with answers 3 years 6 months ago #91726

  • Serafim
  • Serafim's Avatar
  • Offline
  • Expert Lime
  • Posts: 115
  • Thank you received: 2
  • Karma: 2
Maybe I'm doing something wrong, but I don't have any JavaScript errors. I took the code to hide the question to see it work, it chooses the right answers, but in the second question it doesn't shows anything.
Attachments:
The administrator has disabled public write access.

Please Help, hidden question with answers 3 years 6 months ago #91760

  • tpartner
  • tpartner's Avatar
  • Online
  • LimeSurvey Team
  • Posts: 6204
  • Thank you received: 1374
  • Karma: 538
Ah, to have it all on one page, you will need to fire the checkconditions() function after checking the boxes:
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		// Get the question ID and the token values
		var qID = '{QID}';
		var dept1 = '{TOKEN:ATTRIBUTE_1}';
		var dept2 = '{TOKEN:ATTRIBUTE_2}';
		var dept3 = '{TOKEN:ATTRIBUTE_3}';
		var dept4 = '{TOKEN:ATTRIBUTE_4}';
 
		// Hide the question
		$('#question'+qID).css({
			'position':'absolute',
			'left':'-9999em'
		});
 
		// Check the appropriate boxes
		if(dept1 == 'Y') {
			checkTheBox($('#question'+qID+' input[type="checkbox"]:eq(0)'));
		}
		if(dept2 == 'Y') {
			checkTheBox($('#question'+qID+' input[type="checkbox"]:eq(1)'));
		}
		if(dept3 == 'Y') {
			checkTheBox($('#question'+qID+' input[type="checkbox"]:eq(2)'));
		}
		if(dept4 == 'Y') {
			checkTheBox($('#question'+qID+' input[type="checkbox"]:eq(3)'));
		}
 
		function checkTheBox(el) {
			$(el).attr('checked', true);
			checkconditions($(el).attr('value'), $(el).attr('name'), $(el).attr('type'));
		}
	});
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Please Help, hidden question with answers 3 years 6 months ago #91763

  • Serafim
  • Serafim's Avatar
  • Offline
  • Expert Lime
  • Posts: 115
  • Thank you received: 2
  • Karma: 2
Ahh, nice, just perfect.

Only one thing, maybe in css I can solve it, as the first question is hidden, how can I take the space that it takes visually? What I mean is, question by question, I have to submit the first question or a empty screen to go to the second question, if it is every questions in a page, there is an empty space (+-3 lines) before the second question. I'm sure that in the css I can do this, and just show the second question right?

Any way, just the case of this code working is perfect for me, it was my big problem, to use attributes as answers. Thanks.
The administrator has disabled public write access.

Please Help, hidden question with answers 3 years 6 months ago #91916

  • Serafim
  • Serafim's Avatar
  • Offline
  • Expert Lime
  • Posts: 115
  • Thank you received: 2
  • Karma: 2
Hi there, any suggestions?
The administrator has disabled public write access.

Please Help, hidden question with answers 3 years 6 months ago #91962

  • Serafim
  • Serafim's Avatar
  • Offline
  • Expert Lime
  • Posts: 115
  • Thank you received: 2
  • Karma: 2
I´m back again!

So, 2 questions:

1. This code is life saving to my surveys, just need a little help, if I have my survey to appear question by question, is it possible to not show the page with the hidden question? Because if my survey is question by question I have one screen with no question that I have to click next.

2. One different thing, using the previous answers for my present question, it will show m previous questions in the "Y" label, is it possible to show my previous answers in the "X" label?
The administrator has disabled public write access.

Please Help, hidden question with answers 3 years 6 months ago #91964

  • tpartner
  • tpartner's Avatar
  • Online
  • LimeSurvey Team
  • Posts: 6204
  • Thank you received: 1374
  • Karma: 538
1) If you do not have a "Previous" button, you can have JavaScript auto-submit the page:
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		// Hide the page
		$('body').hide();
 
		// Get the question ID and the token values
		var qID = '{QID}';
		var dept1 = '{TOKEN:ATTRIBUTE_1}';
		var dept2 = '{TOKEN:ATTRIBUTE_2}';
		var dept3 = '{TOKEN:ATTRIBUTE_3}';
		var dept4 = '{TOKEN:ATTRIBUTE_4}';
 
		// Hide the question
		$('#question'+qID).css({
			'position':'absolute',
			'left':'-9999em'
		});
 
		// Check the appropriate boxes
		if(dept1 == 'Y') {
			checkTheBox($('#question'+qID+' input[type="checkbox"]:eq(0)'));
		}
		if(dept2 == 'Y') {
			checkTheBox($('#question'+qID+' input[type="checkbox"]:eq(1)'));
		}
		if(dept3 == 'Y') {
			checkTheBox($('#question'+qID+' input[type="checkbox"]:eq(2)'));
		}
		if(dept4 == 'Y') {
			checkTheBox($('#question'+qID+' input[type="checkbox"]:eq(3)'));
		}
 
		// Submit the page
		document.limesurvey.move.value = 'movenext';
		$('form#limesurvey').submit();
 
		function checkTheBox(el) {
			$(el).attr('checked', true);
			checkconditions($(el).attr('value'), $(el).attr('name'), $(el).attr('type'));
		}
	});
</script>

2) I'm afraid I don't understand the question.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Please Help, hidden question with answers 3 years 6 months ago #91969

  • Serafim
  • Serafim's Avatar
  • Offline
  • Expert Lime
  • Posts: 115
  • Thank you received: 2
  • Karma: 2
OK, thanks for the first question, it´s perfect, the survey works just fine.

The second question, sorry for my English, sometimes is hard to explain. So in a grid question, in my previous question I answered which department, now I want to rate those departments in some cases.

In my question, in the left I have the departments, and on top I have the cases, under the cases I choose from a drop list from 1 to 10 to rate. That is what I have now, and do remember that the departments are answers from a previous question. Is it possible to change that? Put my departments on top and the cases on the left? I tried to change but it wouldn't get my previous answers...

Once again many thanks and sorry for my English.
The administrator has disabled public write access.

Please Help, hidden question with answers 3 years 6 months ago #91978

  • tpartner
  • tpartner's Avatar
  • Online
  • LimeSurvey Team
  • Posts: 6204
  • Thank you received: 1374
  • Karma: 538
I don't think you can do that. You can't filter columns of arrays.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Please Help, hidden question with answers 3 years 6 months ago #91992

  • Serafim
  • Serafim's Avatar
  • Offline
  • Expert Lime
  • Posts: 115
  • Thank you received: 2
  • Karma: 2
Ok, anyway many thanks for all your help.
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.284 seconds
Imprint                   Data Protection Statement                  Revocation information and revocation form