Welcome to the LimeSurvey Community Forum

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

SOLVED - Triple-scale array question? Matrix with different scales

  • DamianP
  • DamianP's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 6 months ago - 4 years 6 months ago #189246 by DamianP
Hello Lime-Geniuses!

Is there a good soul that can help me? :unsure:


I was wondering if i can do the triple-scale array question with different scales?

I have been reading for a while and what i have found for now (which i think is the closest to solution) is merging 3 questions with some JS.

However people say it works only for the same type of questions. I really need it to be like in the attached file.

Unfortunetaly i don't know JS :( Is it hard to write a code that would change a dual-scale array for triple-scale? Or maybe there is some other solution?


Any help would be much appreciated Guys!

Damian.
Attachments:
Last edit: 4 years 6 months ago by DamianP.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 months ago #189253 by Joffm
Hi,
you can do this




Put this into the question text.
Code:
<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="">select...</option>\
  <option value="1">Tak</option>\
  <option value="2">Nie</option>\
  <option value="3">Nie wiem</option>\
</select>');     
$('.answer-item.answer_cell_X002', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\
  <option value="">select...</option>\
  <option value="1">Tak</option>\
  <option value="2">Nie</option>\
  <option value="3">Nie wiem</option>\
</select>'); 
$('.answer-item.answer_cell_X003', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\
  <option value="">select...</option>\
  <option value="1">Bardzo male</option>\
  <option value="2">Male</option>\
  <option value="3">Srednie</option>\
  <option value="4">Duze</option>\
  <option value="5">Bardzo duze</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>

As you might have seen:
The codes of the x-scale are: "X001", "X002", ...

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DamianP
The topic has been locked.
  • DamianP
  • DamianP's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 6 months ago #189256 by DamianP
Really really big thanks for your engagement!

However, we have 60 subquestions, so it will be hard for our respondents to click 180 times to unfold the responses.
I guess it is not possible to change it into radio buttons?

Sorry for beeing that picky. I really appreciate you responded in the first place. Not mentioning that You have provided me with a copy-paste code! :)
The topic has been locked.
  • DamianP
  • DamianP's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 6 months ago - 4 years 6 months ago #189307 by DamianP
I found a guy who figured it out for me.

So if anyone has the same problem - Enjoy the solution :)
One thing you have to remember - The triple array cannot be the first question or group in the survey.

LSS and LSG attached.

Thanks one more time @Joffm!!
Last edit: 4 years 6 months ago by DamianP.
The following user(s) said Thank You: holch
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose