Survey 615 es-CO gid sid group_order randomization_group grelevance id gid group_name description language sid group_order randomization_group grelevance qid parent_qid sid gid type title preg other mandatory encrypted question_order scale_id same_default relevance question_theme_name modulename same_script <![CDATA[Q00]]> qid parent_qid sid gid type title preg other mandatory encrypted question_order scale_id same_default relevance question_theme_name modulename same_script <![CDATA[SQ001]]> <![CDATA[SQ001]]> <![CDATA[SQ002]]> <![CDATA[SQ003]]> <![CDATA[SQ004]]> <![CDATA[SQ002]]> <![CDATA[SQ003]]> id qid question help script language $(document).on('ready pjax:scriptcomplete', function() { var thisQuestion = $('#question{QID}'); // Reemplazar los campos de texto con campos de selección en la matriz SQ001 $('.answer-item.answer_cell_SQ001', thisQuestion).addClass('with-select').append(''); // Listener on color select elements $('.inserted-select', thisQuestion).on('change', function() { var selectedColor = $(this).val(); var personInput = $(this).closest('.answer-item').siblings('.answer-item.answer_cell_SQ002').find('input[type="text"]'); // Mostrar la persona correspondiente o limpiar el campo if (selectedColor === 'Rojo') { personInput.val('Morado'); } else if (selectedColor === 'Azul') { personInput.val('Ana'); } else if (selectedColor === 'Amarillo') { personInput.val('Juan'); } else if (selectedColor === 'Verde') { personInput.val('Luis'); } else { personInput.val(''); } }); // Inicialización de selects al cargar la página $('.with-select input:text', thisQuestion).each(function() { 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).trigger('change'); }); // Limpieza de estilos $('select.inserted-select', thisQuestion).css({ 'max-width': '100%' }); $('.with-select input:text', thisQuestion).css({ 'position': 'absolute', 'left': '-9999em' }); // Nueva lógica para SQ003 y SQ004 // Reemplazar el campo de texto existente en SQ003 con campos de selección $('.answer-item.answer_cell_SQ003 input[type="text"]', thisQuestion).replaceWith(''); // Listener on country select elements $('.inserted-select-country', thisQuestion).on('change', function() { var selectedCountry = $(this).val(); var personInput = $(this).closest('.answer-item').siblings('.answer-item.answer_cell_SQ004').find('input[type="text"]'); // Mostrar la persona correspondiente o limpiar el campo if (selectedCountry === 'Colombia') { personInput.val('Carlos'); } else if (selectedCountry === 'Argentina') { personInput.val('María'); } else if (selectedCountry === 'Brasil') { personInput.val('Pedro'); } else if (selectedCountry === 'Chile') { personInput.val('Sofia'); } else { personInput.val(''); } }); // Inicialización de selects de países al cargar la página $('.with-select input:text', thisQuestion).each(function() { var thisCell = $(this).closest('.answer-item'); var inputText = $.trim($(this).val()); var selectval = $('select.inserted-select-country option', thisCell).filter(function() { return $(this).html() == inputText; }).val(); $('select.inserted-select-country', thisCell).val(selectval).trigger('change'); }); // Limpieza de estilos para selects de países $('select.inserted-select-country', thisQuestion).css({ 'max-width': '100%' }); }); ]]>