Welcome to the LimeSurvey Community Forum

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

Re-order "other" option in multiple choice question.

  • tammo
  • tammo's Avatar Topic Author
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
7 years 9 months ago - 7 years 9 months ago #137696 by tammo
I am quite sure I have seen an answer, most probable by tpartner to this question, but after some searching I have not found it.

I have a multiple choice question where the "other" option should not be the last one. It should be like this:

[ ] Answer A
[ ] Answer B
[ ] Answer C
[ ] Other: _____
[ ] None of the above

Can anyone indicate the direction where I can find a solution for this? Thanks in advance.


Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
Last edit: 7 years 9 months ago by tammo.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago #137702 by tpartner
Hi Tammo, LimeSurvey version?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • tammo
  • tammo's Avatar Topic Author
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
7 years 9 months ago #137703 by tammo
2.50, 160606


Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago #137704 by tpartner
Add this script to the question source and adjust "otherOffset" as necessary:

Code:
<script type="text/javascript" charset="utf-8">    
  $(document).ready(function(){
 
    var otherOffset = 1;
 
    var newOtherIndex = ($('#question{QID} div.question-item').length-(otherOffset+1));
 
    $('#question{QID} div.question-item:eq('+newOtherIndex+')').parent().before($('#question{QID} div.question-item[id$="other"]').parent());
  });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: tammo, coeneisma
The topic has been locked.
  • tammo
  • tammo's Avatar Topic Author
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
7 years 9 months ago #137706 by tammo
This works!

Thank you very much!

Tammo


Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
The topic has been locked.
More
7 years 1 month ago #148764 by RaCMJS
Is there a way to make this work on an older version (Version 2.05+ Build 150310)? Currently don't have the capacity to upgrade. I tried this solution and it doesn't work. Is there another work around that might work?

Thanks,
S
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 1 month ago #148765 by tpartner
For 2.05 and 2.06:

Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){
 
    var otherOffset = 1;
 
    var newOtherIndex = ($('#question{QID} .question-item').length-(otherOffset+1));
 
    $('#question{QID} .question-item:eq('+newOtherIndex+')').before($('#question{QID} .question-item[id$="other"]'));
  });
</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.
More
7 years 1 month ago #148766 by RaCMJS
Thank you so much! This works!
The topic has been locked.
More
4 years 11 months ago #182288 by ecoplan
With the new LS 3.16 the script is not working anymore.
If you could help adapt it I'd be very thankful.

Kind regards, Simon
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 11 months ago - 4 years 11 months ago #182291 by tpartner
This script works in 3.16.x:

Code:
<script type="text/javascript" charset="utf-8">
 
  $(document).on('ready pjax:scriptcomplete',function(){
 
    var otherOffset = 1;
 
    var newOtherIndex = ($('#question{QID} .question-item').length-(otherOffset+1));
 
    $('#question{QID} .question-item:eq('+newOtherIndex+')').before($('#question{QID} .question-item[id$="other"]'));
  });  
</script>



Sample survey attached:

File Attachment:

File Name: limesurvey...3-26.lss
File Size:31 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 4 years 11 months ago by tpartner.
The following user(s) said Thank You: DenisChenu, ecoplan
The topic has been locked.
More
4 years 11 months ago #182295 by ecoplan
Flawless as always, thanks tpartner!
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 11 months ago #182296 by tpartner
You are welcome.

One note: as with all of my workarounds, I suggest disabling AJAX in the survey theme options.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: ecoplan, cdorin
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose