Welcome to the LimeSurvey Community Forum

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

Anchor answer options at the bottom of question

  • Matadeleo
  • Matadeleo's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
6 years 1 month ago #163483 by Matadeleo
Hi, as the title says I'm looking to fix a variable number of answer options at the bottom of a list. The idea is basically to have a random order list, with options such as "Don't know" and "None of these" fixed at the bottom.

I used workaround code that enabled me to do this in the past, however trying to use it on my current installation doesn't appear to work.
Code:
<script type="text/javascript" charset="utf-8">  
 
  $(document).ready(function() {
 
    // The number of answers to be fixed at the end of the list
    var fixedAnswers = 2;
 
    // Identify this question
    var qID = {QID}; 
 
    // Find the number of answers
    var ansCount = $('#question'+qID+' li.answer-item').length;
 
    // Place the last n answers created at the end of the list
    var fixedIndex = fixedAnswers - 1;
    for (var i=0; i<fixedAnswers; i++) {
      var answer = $( 'input[id$="X'+qID+(ansCount-fixedIndex)+'"]');
      var answerItem = $(answer).closest('li');
      var answersList = $(answer).closest('ul');
      $(answersList).append(answerItem);
      fixedIndex--;
    }    
  });
</script>


Server is set up to use Javascript and if I attempt to use a different workaround then it works fine.
The topic has been locked.
More
6 years 1 month ago #163486 by jelo
How should anybody know what your current installation is?
You better attach a small survey with your question and the notworking workaround.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • Matadeleo
  • Matadeleo's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
6 years 1 month ago #163488 by Matadeleo
Replied by Matadeleo on topic Anchor answer options at the bottom of question
Hi Jelo,

I've tested it on three servers, v2.0.5, v2.65 and v3.1.1.

v2.0.5 works correctly, the others appear to be unaffected by the workaround.

I've attached an example survey as requested.

File Attachment:

File Name: anchoring_...2-05.lss
File Size:21 KB
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 1 month ago - 6 years 1 month ago #163489 by tpartner
Please refer to the manual. I updated that workaround some time ago with solutions for both 2.06 and 2.73 (which should also work in 3.x).

- manual.limesurvey.org/Workarounds:_Manip...tions_.28Enhanced.29 .

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 6 years 1 month ago by tpartner.
The topic has been locked.
  • Matadeleo
  • Matadeleo's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
6 years 1 month ago #163492 by Matadeleo
Replied by Matadeleo on topic Anchor answer options at the bottom of question
Thanks tpartner, I have tested that workaround and working fine at 3.1.1

Interestingly, testing it at v2.65 (below your version it was created for) - working for multiple choice but not for single :)
The topic has been locked.
More
3 years 9 months ago #201374 by jfrey1
Hello. I tried using the code above to accomplish this, but it didn't work. My question type is multiple choice, with an exclusive option "None of the above" that is automatically anchored. This question also contains an "Other" option that I'd like to anchor at the bottom of the list. A screenshot is attached.

LimeSurvey version: Version 4.2.6+200602
Question type: Multiple choice (M)
Question code: G02Q02
"Other" value: 15
"None of the above" value: 16
Attachments:
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 9 months ago - 3 years 9 months ago #201447 by tpartner
This code thread is about anchoring answer options, not sub-questions. Please start a new topic and include a sample survey (.lss file) containing only one question.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 3 years 9 months ago by tpartner.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose