Welcome, Guest
Username: Password: Remember me

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

Hide answer option with EM, is it possible? 1 month 2 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 month 2 weeks ago #111583

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4207
  • Thank you received: 791
  • Karma: 360
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.
Moderators: ITEd
Time to create page: 0.109 seconds
Donation Image