Welcome to the LimeSurvey Community Forum

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

Tipo de pregunta ARRAY

  • brauliofirpo77
  • brauliofirpo77's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 9 months ago #201987 by brauliofirpo77
Tipo de pregunta ARRAY was created by brauliofirpo77
Estimados, buenos dias

Tengo que hacer una pregunta del tipo array numerico, pero con las siguientes condiciones

1. el primer campo debe ser numerico
2. el segundo debe ser un desplegable
3. la suma de todos los valores que estan en la primera columna, debe ser siempre = 100%

Con respecto al primer y tercer punto, ya lo tengo medianamente resuelto, pero no le encuentro la manera para resolver el segundo.

Alguien tiene una idea?

Muchas gracias!
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 9 months ago #201997 by Joffm
Replied by Joffm on topic Tipo de pregunta ARRAY
Asi?



Mañana mas.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • brauliofirpo77
  • brauliofirpo77's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 9 months ago #202003 by brauliofirpo77
Replied by brauliofirpo77 on topic Tipo de pregunta ARRAY
Exacto.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 9 months ago #202014 by Joffm
Replied by Joffm on topic Tipo de pregunta ARRAY
Hola,

bueno, aqui el javascript
Code:
<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:scriptcomplete',function(){
    var thisQuestion = $('#question{QID}');
 
    // Insert selects
    $('.answer-item.answer_cell_X002', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\
                          <option value="">...</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>'); 
 
    // 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>

y el ejemplo.

File Attachment:

File Name: limesurvey...8329.lss
File Size:22 KB


Mira la ecuación de validación.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • brauliofirpo77
  • brauliofirpo77's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 9 months ago #202096 by brauliofirpo77
Replied by brauliofirpo77 on topic Tipo de pregunta ARRAY
muchas gracias!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose