- Posts: 10216
- Thank you received: 3635
Ask the community, share ideas, and connect with other LimeSurvey users!
var thisCode = $(this).attr('id').split('X'+q1ID)[1];
Tpartner mentioned group and question id. No survey id. I don't understand the releation to a new installation and the first survey on such a installtion?holch wrote: because the problem would only appear if it was the first survey ever in a new installation, right?
I thought when creating a new survey gid starts for every survey with one. Which isn't the case as I learned today Created a new survey on demo.limesurvey.org and got GID 74 and QID 2222 on the first question. Thanks.tpartner wrote: Since this is the first group and question in Holch's install, both the group and question IDs are "1",
$(document).on('ready pjax:scriptcomplete',function(){ // Apply the plugin to specific arrays $('.array-multi-flexi.with-checkbox-array-comments').cbArrayComments(); }); // A jQuery plugin insert comments into checkbox arrays (function( $ ){ $.fn.cbArrayComments = function(options) { var opts = $.extend( { }, options); return this.each(function() { // Identify the questions var thisQuestion = $(this); var q1ID = $(thisQuestion).attr('id').replace(/question/, ''); var thisQuestion = $('#question'+q1ID); var nextQuestion = thisQuestion.nextAll('.multiple-short-txt:eq(0)'); var q2ID = $(nextQuestion).attr('id').replace(/question/, ''); //Hide the multiple-short-text nextQuestion.hide(); // Move the text inputs $('tr.subquestion-list', thisQuestion).each(function(i) { var thisCode = $(this).attr('id').split('X')[2].split(q1ID)[1]; $('td.answer-item:last input[type="checkbox"]', this).css({ 'position': 'absolute', 'left': '-9999em' }); $('td.answer-item:last', this).removeClass('checkbox-item').addClass('inserted-text-item').append($('input[type="text"][id$="X'+q2ID+thisCode+'"]', nextQuestion)); }); // Listeners on the text inputs $('input[type="text"]', thisQuestion).on('keyup change', function(e) { var thisCheckbox = $(this).closest('td').find('input[type="checkbox"]'); if($.trim($(this).val()) != '') { $(thisCheckbox).prop('checked', true); $(thisCheckbox).prev('input:hidden').val(1); } else { $(thisCheckbox).prop('checked', false); $(thisCheckbox).prev('input:hidden').val(''); } // Fire Expression manager $(thisCheckbox).trigger('change'); }); }); }; })( jQuery );