Welcome to the LimeSurvey Community Forum

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

Filter on dropdown menu values

  • bianconijo
  • bianconijo's Avatar Topic Author
  • Offline
  • Bronze Donor
  • Bronze Donor
More
6 years 11 months ago - 6 years 11 months ago #154914 by bianconijo
Filter on dropdown menu values was created by bianconijo
Ciao,
I have the following situation:

Group of questions 1: the participant must select the first teacher to evaluate from a dropdown menu containing more than 90 values. This group of questions three more questions (arrays) on the characteristics of the teacher.

After the evaluation of the first teacher is accomplished, the participant goes to Group of questions 2.

In this group of question, there's the same dropdown menu from where the participant must pick the second teacher to evaluate. This group of questions three more questions (arrays) on the characteristics of the teacher.

And so on. Approximately, each participant will have to evaluate ten teachers out of 90.

To prevent a paricipant from evaluating the same teacher twice or more (by mistake or on purpose), is it possible to remove from the dropdown the names of the teachers already picked and evaluated?

The survey is public (just a link), no token.

For example (see attached):
in Group of questions 1, I can choose between 5 teachers: Brown Charlie, Green Peter, Pink Anna, Red Maurus, Yellow Steve. Let's assume I evaluate Green Peter. In the next group of questions (2) I will be able to select only one the following:
Brown Charlie, Pink Anna, Red Maurus, Yellow Steve (Green Peter does not show up anymore because I have already evaluated him).

Thanks for your support in this matter.

BC
Last edit: 6 years 11 months ago by bianconijo.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 11 months ago #154915 by tpartner
Replied by tpartner on topic Filter on dropdown menu values
There is no built-in filtering for list-dropdown questions but you could insert your own with JavaScript.

For examples sake, let's say the question codes of the dropdowns are "teacher1", "teacher2"..."teacher10".

Set up your survey to use JavaScript and place the following script in the question source of teacher2:
Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function() { 
    $('#question{QID} option[value="{teacher1}"]').remove();  
  });
</script>

Place this in the question source of teacher3:
Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function() { 
    $('#question{QID} option[value="{teacher1}"]').remove();     
    $('#question{QID} option[value="{teacher2}"]').remove();
  });
</script>

Place this in the question source of teacher4:
Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function() { 
    $('#question{QID} option[value="{teacher1}"]').remove();     
    $('#question{QID} option[value="{teacher2}"]').remove();   
    $('#question{QID} option[value="{teacher3}"]').remove();
  });
</script>

...and so on.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • bianconijo
  • bianconijo's Avatar Topic Author
  • Offline
  • Bronze Donor
  • Bronze Donor
More
6 years 11 months ago #154916 by bianconijo
Replied by bianconijo on topic Filter on dropdown menu values
Works like a charm!

Thanks for your time.

BC
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose