Welcome to the LimeSurvey Community Forum

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

array with text in last column

  • Maribelcarol
  • Maribelcarol's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 4 months ago #208918 by Maribelcarol
array with text in last column was created by Maribelcarol
Hi. I'd like to do an array, though in the last column I'd like to give the option to write some comments insted of a checkbox. Also I'd like to know if below each subquestion line, I could add a line just with text for reading as you can see the image. Thanks a lot.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 4 months ago #208922 by Joffm
Replied by Joffm on topic array with text in last column
Hi,
I could offer this.
So you have enough space for comments.
The results of the last round are fixed values, aren't they.



Otherwise you can merge 4 question of type "array" and four questions of type "array(text)" where you enter the last round.
Merged with the css classes "no-question" and "no-bottom" to display all arrays connected to each other.
Tomorrow I'll give an example.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 4 months ago #208942 by Joffm
Replied by Joffm on topic array with text in last column
Hi,
here a new idea that seems to be a good solution.



For the "result table" have a look at the subquestions. Can be improved, because you always have to consider that people answer the survey on small devices.

The array itself is created by this javascript
Code:
<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:scriptcomplete',function(){
    var thisQuestion = $('#question{QID}');
    // Add a question class
    thisQuestion.addClass('custom-array');
 
    // Column-specific classes
    $('table.subquestion-list tr', thisQuestion).each(function(i) {
      $('th, td', this).each(function(i) {
        $(this).addClass('column-'+i);
      });
    });
 
 
    // Insert selects
    $('.answer-item.answer_cell_X001', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\
  <option value="">...</option>\
  <option value="1">strongly disagree</option>\
  <option value="2">disagree</option>\
  <option value="3">neutral</option>\
  <option value="4">agree</option>\
  <option value="5">strongly agree</option>\
  <option value="6">don\'t know</option>\
</select>');
 
 
 
    // Listeners
    $('.inserted-select', thisQuestion).on('change', function(i) {
      if($(this).val() != '') {
        $(this).closest('.answer-item').find('input:text').val($('option:selected', this).val()).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());
      $('select.inserted-select', thisCell).val(inputText);
    });
 
    // Clean-up styles
    $('select.inserted-select', thisQuestion).css({
      'max-width': '100%'
    });
    $('.with-select input:text', thisQuestion).css({
      'position': 'absolute',
      'left': '-9999em'
    });
  });
</script>

and this css:
Code:
<style type="text/css">.custom-array table.subquestion-list col {
    width: auto !important;
  }
 
  .custom-array table.subquestion-list thead .column-0 {  width: 35%; }
  .custom-array table.subquestion-list thead .column-1 {  width: 15%; }
  .custom-array table.subquestion-list thead .column-2 {  width: 50%; }
</style>

Both you enter into the question text (in source code mode)

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • Maribelcarol
  • Maribelcarol's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 4 months ago #208966 by Maribelcarol
Replied by Maribelcarol on topic array with text in last column
Thank you so much!!! I think the last table is great.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 4 months ago - 3 years 4 months ago #208967 by Joffm
Replied by Joffm on topic array with text in last column
Hi,sorry,

I forgot to add the sample

File Attachment:

File Name: limesurvey...1_JK.lss
File Size:25 KB



Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 4 months ago by Joffm.
The following user(s) said Thank You: Maribelcarol
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose