Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Matriz número con una opción excluyente

  • Agomez5
  • Agomez5's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 10 months ago #199753 by Agomez5
Hola, tengo una pregunta sobre matriz de número donde tengo en las columnas marcas y en las filas atributos. Mi pregunta es cómo hacer que una marca se unica y excluya marcar el resto y el resto de las marcas sean multiples.

Ejemplo

Marca marca ninguno
Atrib. Rm. rm. ru
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 10 months ago #199755 by Joffm
Replied by Joffm on topic Matriz número con una opción excluyente
¿así?


Pegue el script en el texto de la pregunta (modo de código fuente)
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Call the exclude function using question ID
excludeOpt({QID});
});

// A function to make the "numCol" option in each array row exclusive
function excludeOpt (qID) {

var thisQuestion = $('#question'+qID)
// Set the desired exclusive column
var numCol = 3; //Here fourth col

// Add some classes to the checkbox cells
$('td.checkbox-item', thisQuestion).addClass('normal-item');
$('tr.subquestion-list', thisQuestion).each(function(i) {
$('.normal-item:eq('+numCol+')', this).removeClass('normal-item').addClass('exlusive-item')
});

// A listener on the checkboxes
$('input[type="checkbox"]', thisQuestion).on('change', function (event) {
handleExclusive($(this).closest('td'));
});

function handleExclusive(thisCell) {

var thisRow = $(thisCell).closest('tr');

// Uncheck the appropriate boxes in a row
if ($(thisCell).hasClass('normal-item')) {
$('.exlusive-item input[type="checkbox"]', thisRow).prop('checked', false);
}
else {
$('.normal-item input[type="checkbox"]', thisRow).prop('checked', false);
}

// Check conditions (relevance)
$('td.checkbox-item', thisRow).each(function(i) {
var thisValue = '';
if($('input[type="checkbox"]', this).is(':checked')) {
thisValue = 1;
}
var thisSGQA = $('input[type="checkbox"]', this).attr('id').replace(/cbox_/, '');

$('input[type="hidden"]', this).attr('value', thisValue);
fixnum_checkconditions(thisValue, thisSGQA, 'hidden');
});
}
}
</script>


Esto ha sido probado en la versión 3.x.
¿Qué versión usas?

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose