- Posts: 20
- 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 pjax:scriptcomplete',function(){ var thisQuestion = $('#question{QID}'); // Insert selects $('.answer-item.answer_cell_X001', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\ <option value="">Por favor...</option>\ <option value="1">rojo</option>\ <option value="2">azul</option>\ <option value="3">amarillo</option>\ <option value="4">verde</option>\ </select>'); $('.answer-item.answer_cell_X002', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\ <option value="">Por favor...</option>\ <option value="1">opcion 1</option>\ <option value="2">opcion 2</option>\ <option value="3">opcion 3</option>\ <option value="4">opcion 4</option>\ </select>'); $('.answer-item.answer_cell_X003', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\ <option value="">Por favor...</option>\ <option value="1">Una ora</option>\ <option value="2">Dos oras</option>\ <option value="3">Tres oras o mas</option>\ </select>'); $('.answer-item.answer_cell_X004', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\ <option value="">Por favor...</option>\ <option value="1">Pato</option>\ <option value="2">Ganso</option>\ <option value="3">Pavo</option>\ </select>'); $('.answer-item.answer_cell_X005', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\ <option value="">Por favor...</option>\ <option value="1">HONDA</option>\ <option value="2">TOYOTA</option>\ <option value="3">NISSAN</option>\ <option value="3">MITSUBISHI</option>\ </select>'); // Listeners $('.inserted-select', thisQuestion).on('change', function(i) { if($(this).val() != '') { $(this).closest('.answer-item').find('input:text').val($.trim($('option:selected', this).text())).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()); var selectval = $('select.inserted-select option', thisCell).filter(function () { return $(this).html() == inputText; }).val(); $('select.inserted-select', thisCell).val(selectval); }); // Clean-up styles $('select.inserted-select', thisQuestion).css({ 'max-width': '100%' }); $('.with-select input:text', thisQuestion).css({ 'position': 'absolute', 'left': '-9999em' }); }); </script>
Tengo instalada la versión 3.17 de limesurvey. Necesito hacer una matriz con mas de 2 escalas con lista desplegable