Disable specific boxes (=answer options) in a array question (numbers)

More
2 months 3 weeks ago #196691 by tpartner
Can you please provide a screenshot/mockup and a small sample survey (.lss file) containing only the relevant question?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
The following user(s) said Thank You: zserban

Please Log in to join the conversation.

More
2 months 3 weeks ago #196706 by zserban

tpartner wrote: Can you please provide a screenshot/mockup and a small sample survey (.lss file) containing only the relevant question?



Hi tpartner, thank you for taking the time!

I inserted the code I found here in the array question.

It does the job (hiding the row 4 and 12 for answer 6. These rows correspond to subquestions 4 and 12, which shouldn't be answered by option 6.), but the random - which is a must - is messing it up.
Attachments:

Please Log in to join the conversation.

More
2 months 3 weeks ago #196719 by holch
Any specific reason why you zipped the LSS file?

You can upload it directly to the forum. One step less for Tpartner to help you.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The following user(s) said Thank You: zserban

Please Log in to join the conversation.

More
2 months 3 weeks ago #196721 by zserban
Oh, out of habbit.


Also, forgot to mention, is Limesurvey 3 branch (the latest public release)

Please Log in to join the conversation.

More
2 months 3 weeks ago - 2 months 3 weeks ago #196740 by tpartner
You can target the rows with the sub-question codes like this:

<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		// Remove row 4, answer "6"
		$('#question{QID} tr.answers-list[id$="X{QID}4"] input:radio[value="6"]').nextAll('label').remove();
		$('#question{QID} tr.answers-list[id$="X{QID}4"] input:radio[value="6"]').remove();
 
		// Remove row 12, answer "6"
		$('#question{QID} tr.answers-list[id$="X{QID}12"] input:radio[value="6"]').nextAll('label').remove();
		$('#question{QID} tr.answers-list[id$="X{QID}12"] input:radio[value="6"]').remove();
	});	
</script>

This part of the selector - tr.answers-list[id$="X{QID}12"] - effectively says "row with ID ending in X + Question ID + SQ Code 12".

Sample survey attached:

File Attachment:

File Name: limesurvey...4431.lss
File Size:47 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
Attachments:
Last edit: 2 months 3 weeks ago by tpartner.
The following user(s) said Thank You: zserban

Please Log in to join the conversation.

More
2 months 3 weeks ago #196744 by zserban

tpartner wrote: You can target the rows with the sub-question codes like this:

<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		// Remove row 4, answer "6"
		$('#question{QID} tr.answers-list[id$="X{QID}4"] input:radio[value="6"]').nextAll('label').remove();
		$('#question{QID} tr.answers-list[id$="X{QID}4"] input:radio[value="6"]').remove();
 
		// Remove row 12, answer "6"
		$('#question{QID} tr.answers-list[id$="X{QID}12"] input:radio[value="6"]').nextAll('label').remove();
		$('#question{QID} tr.answers-list[id$="X{QID}12"] input:radio[value="6"]').remove();
	});	
</script>

This part of the selector - tr.answers-list[id$="X{QID}12"] - effectively says "row with ID ending in X + Question ID + SQ Code 12".

Sample survey attached:

File Attachment:

File Name: limesurvey...4431.lss
File Size:47 KB



It works very well! I really appreciate it (and others will do too), tpartner.

No doubt, in a similar fashion, you can even filter available answers by responses given at previous questions, something that cannot be done out of the box. This might be quite handy because it could shorten the total number of questions a respondent has to answer.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now