- Posts: 31
- Thank you received: 4
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
check that answers from two identical drop down list are different
- pmonstad
- Topic Author
- Offline
- Junior Member
Less
More
9 years 11 months ago #107176
by pmonstad
check that answers from two identical drop down list are different was created by pmonstad
I have two identical drop down lists. The respondent is supposed to make a first choice from the first list and a second choice from the second list. Making two identical choices make no sense but will certainly happen when several hundred kids are about to answer.
How can I make a check of the two answers? Only continue if the two answers are different, and show an error if they equals redirecting the respondent to make another choice in on of the lists?
How can I make a check of the two answers? Only continue if the two answers are different, and show an error if they equals redirecting the respondent to make another choice in on of the lists?
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11746
- Thank you received: 2750
9 years 11 months ago #107182
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic check that answers from two identical drop down list are different
I assume that the lists are both on the same page?
If they are on different pages, you might be able to use the array_filter (not sure if it works with the dropdowns though.
If they are on different pages, you might be able to use the array_filter (not sure if it works with the dropdowns though.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- pmonstad
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 31
- Thank you received: 4
9 years 11 months ago #107184
by pmonstad
Replied by pmonstad on topic check that answers from two identical drop down list are different
Yes, they are at the same page.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11746
- Thank you received: 2750
9 years 11 months ago #107185
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic check that answers from two identical drop down list are different
I have just checked and the dropdown question doesn't have the option of array filter anyway, so this is not an option. There might be a solution with Javascript, but I have no idea.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3691
9 years 11 months ago #107204
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic check that answers from two identical drop down list are different
Assuming there are only two dropdowns on the page or the dropdowns are sequential, you can
set up your survey to use JavaScript
and add this script to the question source of the first dropdown.
This script will interrupt the submit process and compare the dropdown values.
.
This script will interrupt the submit process and compare the dropdown values.
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify the questions var q1 = $('#question'+{QID}+''); var q2 = $(q1).nextAll('.list-dropdown:eq(0)'); var alertText = 'The two dropdowns cannot have the same answer.'; // On submit, compare the 2 dropdown values $('#movenextbtn, #movesubmitbtn').click(function(){ if($('.answer-item select', q1).val() != '' && $('.answer-item select', q1).val() == $('.answer-item select', q2).val()) { alert(alertText); return false; } }); }); </script>
.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.