- Posts: 3
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
How to remove a multi choice answer based on answer from previous question
- oakeydoke
- Topic Author
- Offline
- New Member
Less
More
6 years 4 months ago #160517
by oakeydoke
How to remove a multi choice answer based on answer from previous question was created by oakeydoke
Hi members
I need to implement a solution where a multi choice - checkbox answers are removed based on an answer from a previous question so:
Previous question is a dropdown select a country:
Code: UK - text: United Kingdom
FR - text: France
PT - text: Portugal
The next question is a multi choice check box:
Code: UK01 - text: Ansenal FC
Code: UK02 - text: Chelsea FC
Code: UK03 - text: Tottenham FC
Code: FR01 - text: Monaco FC
Code: FR02 - text: PSG FC
Code: FR03 - text: Lyon FC
The solution is to hide/remove...
Code: FR01 - text: Monaco FC
Code: FR02 - text: PSG FC
Code: FR03 - text: Lyon FC
from the multi choice check items when UK - United kingdom is selected in previous question.
I have included this script in the source code for question 2:
$(document).ready(function(){
var countryCode = '{INSERTANS:544942X22X666.NAOK}'.substr(0, 2).toUpperCase();
var q1ID = $('#question{QID}');
//alert('Here...1'+q1ID);
$('input.checkbox', q1ID).each(function(i) {
// Find the answer code and value
var ansCode = $(this).attr('name');
var chkCode = ansCode.substr(ansCode.length - 5);
if(chkCode.substr(0, 2) = countryCode){
$(this).hide();
}
});
});
</script>
The problem is "$(this).hide();" does not work!
Thank you very much for your assistance.
Luis
I need to implement a solution where a multi choice - checkbox answers are removed based on an answer from a previous question so:
Previous question is a dropdown select a country:
Code: UK - text: United Kingdom
FR - text: France
PT - text: Portugal
The next question is a multi choice check box:
Code: UK01 - text: Ansenal FC
Code: UK02 - text: Chelsea FC
Code: UK03 - text: Tottenham FC
Code: FR01 - text: Monaco FC
Code: FR02 - text: PSG FC
Code: FR03 - text: Lyon FC
The solution is to hide/remove...
Code: FR01 - text: Monaco FC
Code: FR02 - text: PSG FC
Code: FR03 - text: Lyon FC
from the multi choice check items when UK - United kingdom is selected in previous question.
I have included this script in the source code for question 2:
$(document).ready(function(){
var countryCode = '{INSERTANS:544942X22X666.NAOK}'.substr(0, 2).toUpperCase();
var q1ID = $('#question{QID}');
//alert('Here...1'+q1ID);
$('input.checkbox', q1ID).each(function(i) {
// Find the answer code and value
var ansCode = $(this).attr('name');
var chkCode = ansCode.substr(ansCode.length - 5);
if(chkCode.substr(0, 2) = countryCode){
$(this).hide();
}
});
});
</script>
The problem is "$(this).hide();" does not work!
Thank you very much for your assistance.
Luis
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12713
- Thank you received: 3924
6 years 4 months ago #160521
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic How to remove a multi choice answer based on answer from previous question
Hi, Luis,
first question: Which version of LS do you use?
Since 2.06 forget about scripts.
Just use subquestion relevance in your multiple question, as explained here:
manual.limesurvey.org/Adding_answers_or_subquestions
If you use something below 2.06 consider an update.
Best regards
Joffm
first question: Which version of LS do you use?
Since 2.06 forget about scripts.
Just use subquestion relevance in your multiple question, as explained here:
manual.limesurvey.org/Adding_answers_or_subquestions
If you use something below 2.06 consider an update.
Best regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
The topic has been locked.
- oakeydoke
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
6 years 4 months ago #160523
by oakeydoke
Replied by oakeydoke on topic How to remove a multi choice answer based on answer from previous question
Thanks joffm.
I realised that. I was looking for a dinamic/easy way... because my list of answers in question 2 is rather long!
Luis
I realised that. I was looking for a dinamic/easy way... because my list of answers in question 2 is rather long!
Luis
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12713
- Thank you received: 3924
6 years 4 months ago #160530
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic How to remove a multi choice answer based on answer from previous question
Hi,
just to add:
IMO the easiest way is always the "out of the box" solution.
And even if your multiple quetion has 200 subquestions, it is not too time consuming doing this by copy-paste.
And if it is even longer, remember the column limits.
Regards
Joffm
just to add:
IMO the easiest way is always the "out of the box" solution.
And even if your multiple quetion has 200 subquestions, it is not too time consuming doing this by copy-paste.
And if it is even longer, remember the column limits.
Regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: oakeydoke
The topic has been locked.