Welcome, Guest
Username: Password: Remember me

TOPIC: Hide answer option with EM, is it possible?

Hide answer option with EM, is it possible? 1 year 3 weeks ago #111569

  • marzopiter
  • marzopiter's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 6
  • Thank you received: 3
  • Karma: 1
Hi Folks,
I have 10 token attributes (hospitals that doctors attends)
This is passed as attributes in a list question. One Doctor could attend in many hospital, but one each time. My doubt is: is there any way to remove from the list that one withou information (some doctors could attend from 1 to 10 hospitals, but some could have 3 opiton, another could have 6 ans so on.
In attibute list, I can do something like:
{if(!is_empty({TOKEN:ATTRIBUTE_1}),Q23_1.show,Q23_1.hide)}
{if(!is_empty({TOKEN:ATTRIBUTE_2}),Q23_2.show,Q23_2.hide)}
...
Is this possible? I try with javascript, but I´m missing something, cause just hide the checkbox with this script:

<script>
$(document).ready(function(){
if($('#100052X79X203621').is(':empty')){
$('#100052X79X203621').hide();
}
});
</script>

Could somebody put a light on this, please?
The administrator has disabled public write access.

Hide answer option with EM, is it possible? 1 year 3 weeks ago #111583

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5111
  • Thank you received: 1049
  • Karma: 440
You can add something like this to the source of the multiple-choice question:

<script type="text/javascript" charset="utf-8">	
    $(document).ready(function() { 
 
		// Identify this question
		var thisQuestion = $('#question'+{QID}+'');
 
		// The attribute values
		var attribute1 = '{TOKEN:ATTRIBUTE_1}';
		var attribute2 = '{TOKEN:ATTRIBUTE_2}';
		var attribute3 = '{TOKEN:ATTRIBUTE_3}';
		var attribute4 = '{TOKEN:ATTRIBUTE_4}';
		var attribute5 = '{TOKEN:ATTRIBUTE_5}';
 
		if(attribute1 == '') {
			$('li.question-item:eq(0)', thisQuestion).hide();
		}
		if(attribute2 == '') {
			$('li.question-item:eq(1)', thisQuestion).hide();
		}
		if(attribute3 == '') {
			$('li.question-item:eq(2)', thisQuestion).hide();
		}
		if(attribute4 == '') {
			$('li.question-item:eq(3)', thisQuestion).hide();
		}
		if(attribute5 == '') {
			$('li.question-item:eq(4)', thisQuestion).hide();
		}
	});
</script>
Cheers,
Tony Partner

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Hide answer option with EM, is it possible? 10 months 4 days ago #113991

  • Loktar
  • Loktar's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 15
  • Karma: 0
Nice!

I also wonder if there is a way to hide Answers/Subquestions depending on previous answers.

This could be great to Have answer and subquestion list that adapts to previous answers, because right now i need to create multiple question each time, creating more column in my DB.

Example: on Q3 i have a question that as 3 answers if you are a customer OR 7 i you are an employee. Right now i have no other choice but to create separate questions with all the subquestions, it's a bit messy :/
The administrator has disabled public write access.

Hide answer option with EM, is it possible? 10 months 4 days ago #113997

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5111
  • Thank you received: 1049
  • Karma: 440
If the "respondent type" question is on a previous page and, for example, has a question code of "Q1" and answer codes 1 (customer) and 2 (employee), you can try something like this:

<script type="text/javascript" charset="utf-8">	
    $(document).ready(function() { 
 
		// Identify this question
		var thisQuestion = $('#question'+{QID}+'');
 
		if({Q1.NAOK} == '1') {
			$('li.question-item:eq(3)', thisQuestion).hide();
			$('li.question-item:eq(4)', thisQuestion).hide();
			$('li.question-item:eq(5)', thisQuestion).hide();
			$('li.question-item:eq(6)', thisQuestion).hide();
		}
	});
</script>
Cheers,
Tony Partner

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
The following user(s) said Thank You: Loktar

Hide answer option with EM, is it possible? 10 months 4 days ago #114005

  • Loktar
  • Loktar's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 15
  • Karma: 0
Man, this works perfectly ! Thanks a lot!

Also this kind of features is on the top list of the most demanded feature on LS,
so i guess that a lot of people would benefit your work by knowing this while waiting
for further LS version.


And oh, thanks, again B)
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.182 seconds