Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

How to dinamically remove multi choice - checkbox answers based on previous ques

  • oakeydoke
  • oakeydoke's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 4 months ago #160519 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
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 4 months ago #160522 by Joffm
Hi, Luis,

we do not like cross-posts here.

Your question was answered in the other section.
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 4 months ago #160679 by DenisChenu
Then i close this one :evil:

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose