- Posts: 4
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
tpartner wrote:
Did I hear someone call my name?I asked Dr. Minke about this and he suggested I post on the forum to see if anyone can help adjust the script.
In version 2.54.3, you can use something like this (note, it may not work in future versions if the HTML structure is changed again):
Code:<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // New position of the "Other" row (edit as required) var newPosition = 3; //// NO EDITING REQUIRED BELOW HERE //// var thisQuestion = $('#question{QID}'); var otherRow = $('.answer-item[id$="other"]', thisQuestion).parent(); var replaceRow = $('.answer-item:eq('+(newPosition-1)+')', thisQuestion).parent(); $(replaceRow).before($(otherRow)); }); </script>
Sample survey attached:
<script type='text/javascript' charset='utf-8'> $(document).ready(function() { /* Adjust these settings */ var move_element="other"; var place_before="SQ003"; /* Please do NOT change the lines below */ var place_before="javatbd{SGQ}"+place_before; var move_element="javatbd{SGQ}"+move_element; $("#"+move_element).insertBefore("#"+place_before); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // New position of the "Other" row (edit as required) var newPosition = 3; //// NO EDITING REQUIRED BELOW HERE //// var thisQuestion = $('#question{QID}'); var otherRow = $('.answer-item[id$="other"]', thisQuestion); var replaceRow = $('.answer-item:eq('+(newPosition-1)+')', thisQuestion); $(replaceRow).before($(otherRow)); }); </script>
tpartner wrote: This will work in 3.x:
Code:<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // New position of the "Other" row (edit as required) var newPosition = 3; //// NO EDITING REQUIRED BELOW HERE //// var thisQuestion = $('#question{QID}'); var otherRow = $('.answer-item[id$="other"]', thisQuestion); var replaceRow = $('.answer-item:eq('+(newPosition-1)+')', thisQuestion); $(replaceRow).before($(otherRow)); }); </script>