- Posts: 8
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify the questions var qArray = $('#question{QID}'); var arrayLength = $('tr.answers-list', qArray).length; var qComments = qArray.nextAll('.text-long:lt('+arrayLength+')'); // Add some classes qArray.addClass('array-with-comments-question'); $(qComments).each(function(i) { $(this).addClass('comments-question index-'+i); }); // Insert the comments buttons $('table.questions-list col', qArray).removeAttr('width'); $('table.questions-list thead tr', qArray).append('<td />'); $('tr.answers-list', qArray).each(function(i) { $(this).append('<td><button class="comment-button" type="button" data-index="'+i+'">Comments</button></td>'); }); // Put the comments questions into modal dialogs $(qComments).dialog({ autoOpen: false, width: 620, modal: true, resizable: false, draggable: false, closeOnEscape: true }); // Click events for comments buttons $('.comment-button').click(function() { var thisIndex = $(this).attr('data-index'); $('.comments-question.index-'+thisIndex).dialog('open'); }); // Interrupt the Next/Submit function (to put comments back in the form) $('#movenextbtn, #movesubmitbtn').bind('click', function () { qComments.hide(); $('#limesurvey').append(qComments); }); }); </script>