Welcome to the LimeSurvey Community Forum

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

Dropdown question filtration on same page

  • arnabbhuyan
  • arnabbhuyan's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 1 month ago #227918 by arnabbhuyan
Dropdown question filtration on same page was created by arnabbhuyan
Please help us help you and fill where relevant:
Your LimeSurvey version: Version 3.16.1+190314
Own server or LimeSurvey hosting: Own
Survey theme/template: 
==================
Hello Team,
Looking out for a solution is which there are 2 Dropdown questions in a single page and 2nd Dropdown(filtered) based on selection in 1st dropdown.

The solution i have is based (dropdown questions) on different pages using JS. But when both dropdown questions are on same page JS doesn't work.
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var countryCode = "{Q1Hidden.shown}";
       $('select[id^="answer"] option').each(function(i){

           if($(this).attr('value')  && $(this).attr('value').substr(0,  2).toUpperCase() != countryCode) {
               $(this).remove();
           }
       });
  });
</script>

Looking for some solution.

Thanks in advance.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 1 month ago #227923 by Joffm
Replied by Joffm on topic Dropdown question filtration on same page
Hi,
you asked this already in your other thread.

Well, here is a solution.
As in your shown script the options of the second scale depend on the first two characters of the first scale. All codes 5 characters long.




File Attachment:

File Name: limesurvey...9376.lss
File Size:118 KB


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • arnabbhuyan
  • arnabbhuyan's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 1 month ago #227927 by arnabbhuyan
Replied by arnabbhuyan on topic Dropdown question filtration on same page
Hi Joffm,
Thanks for your quick reply. 
However i tried the way you suggested by no success. May be i missing something in using the suggested example. 
I have attached .lss for your reference.

Secondly as suggested in the screenshot, the 2nd scale is not hidden unless you select something in Scale 1 in your script. Do i need to change in template or any specific template you are using?

Thanks again for your contribution towards Limesurvey.  

File Attachment:

File Name: limesurvey...2483.lss
File Size:25 KB

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 1 month ago #227928 by Joffm
Replied by Joffm on topic Dropdown question filtration on same page
Hi,

by no success

What does this mean?
Is my provided example not shown?
Is it shown but not filtered?
Or what?
I remember, that for a long time there was a typo in the class name of the array.
It was ".array-flexible-duel-scale" instead of ".array-flexible-dual-scale"
I do not know when it was corrected.
As your version is more than three years old you
  • should check this in your webdevelopment tool
  • consider an update
 

i tried the way you suggested

No, you did not.

the second scale depend on the first two characters of the first scale. All codes 5 characters long.

The codes of your first scale have only four characters.
The first two characters do not match in both scales.
You should have studied the example better.

Second point.
What do you want to display in the second scale if the participant clicks this first?
And what do you do with your first scale if this happens?
If you want to show an emty second scale initially you may outcomment this line (line 110 of the script)
$('#'+idNewSelectFilter).hide();


Third:
Are there really this few options?
You may consider a two-level multiple question.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • arnabbhuyan
  • arnabbhuyan's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 1 month ago #227938 by arnabbhuyan
Replied by arnabbhuyan on topic Dropdown question filtration on same page
Hi Joffm,
By saying this:
What does this mean? -- I tried you example just by importing and see whether its working or not. 
Is my provided example not shown? -- No
Is it shown but not filtered? -- No
Or what? -- Attached screenshot for the same



As your version is more than three years old you --  is the code not functioning as required and it requires software update?
  • should check this in your webdevelopment tool
  • consider an update
Third:
Are there really this few options? --No there are many but first tried with few options to check whether its working or not
You may consider a two-level multiple question.

Thanks,
Arnab
 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 1 month ago #227948 by Joffm
Replied by Joffm on topic Dropdown question filtration on same page
So, it is displayed but not filtered.
Did you check for ".array-flexible-duel-scale" vs. ".array-flexible-dual-scale". If it is "duel" in your version you have to adapt the script.
Here what lfanfoni said about this

In one of the latest updates they changed the name of the object that used to be called "array-flexible-duel-scale" and is now called "array-flexible-dual-scale", with "dual" instead of "duel". It is sufficient to make this change to the script to make it work with current versions, certainly starting from version 3.25.21


I developped the example in 3.27.19. As you work with something long before 3.25.21. you may have this "typo issue".

Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose