- 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).on('ready',function(){ var thisSelect = $('#question{QID} input[id^="answer"]:eq(0)'); var secondSelect = $('#question{QID}').nextAll('[id^="question"]:eq(0)').find('input[id^="answer"]:eq(0)'); // Move the first dropdown $('#question{QID} .inserted-dropdown:eq(0)').append(thisSelect); // Move the second dropdown $('#question{QID} .inserted-dropdown:eq(1)').append(secondSelect ); // Hide the next question $('#question{QID}').nextAll('[id^="question"]:eq(0)').hide(); }); </script> <style type="text/css">#question{QID} select { margin: 0 0 0 -0.25em; } </style> <style type="text/css">#question{QID} input { display: inline-block; margin: 0 0 0 -0.25em; width: 50px; height: auto; padding: 0; } #question{QID} .answer-container{ display: none; } </style>
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ var thisQuestion = $('#question{QID}'); // Add a question class thisQuestion.addClass('custom-array'); // Column-specific classes $('table.subquestion-list tr', thisQuestion).each(function(i) { $('th, td', this).each(function(i) { $(this).addClass('column-'+i); }); }); // Insert selects $('.answer-item.answer_cell_X003', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\ <option value="">...</option>\ <option value="1">week</option>\ <option value="2">month</option>\ <option value="3">year</option>\ </select>'); // Listeners $('.inserted-select', thisQuestion).on('change', function(i) { if($(this).val() != '') { $(this).closest('.answer-item').find('input:text').val($('option:selected', this).val()).trigger('change'); } else { $(this).closest('.answer-item').find('input:text').val('').trigger('change'); } }); // Returning to page $('.with-select input:text', thisQuestion).each(function(i) { var thisCell = $(this).closest('.answer-item'); var inputText = $.trim($(this).val()); $('select.inserted-select', thisCell).val(inputText); }); // Clean-up styles $('select.inserted-select', thisQuestion).css({ 'max-width': '100%' }); $('.with-select input:text', thisQuestion).css({ 'position': 'absolute', 'left': '-9999em' }); }); </script>
You see how the "secondSelect" is defined and how the "eq(x)" is used.
Instead of this all, you may use a simple array with a drop-down in the first column and two text fields to enter hours and minutes
This you find in my very first posting.How can I see the secondselect and eq(x) you mention above?
By default LimeSurvey offers the codes of both the y-axis and x-axis as "SQ001", "SQ002"Did you mean that I should replace the x001, x002, x003