Welcome to the LimeSurvey Community Forum

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

Array question with Check box and Text box

More
5 years 5 months ago #195172 by kevinleung
Hi All,

I am going to design a survey.
It is a array like this:

|5 Check box | 1 Text box|
Question 1 | | |
Question 2 | | |
Question 3 | | |
Question 4 | | |
...
Example:


I have found this sample, but it is dropdown list....
www.limesurvey.org/forum/can-i-do-this-w...opdown-list?start=15
Anyone could help me to make the change? thank you!
The topic has been locked.
More
5 years 5 months ago #195330 by Joffm
Hi,
if you don't like the drop-downs, which in my opinion is the best solution so far,
you may have a look at this:

Code:
<script type="text/javascript" charset="utf-8">
 
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Identify the questions
    var qArrayID = {QID};
    var qArray = $('#question'+qArrayID);
//    var arrayLength = $('tr.answers-list', qArray).length;
    var qMultiText = qArray.nextAll('.multiple-short-txt:eq(0)');
 
 
      // Hide the multi-short-text question
    $(qMultiText).hide();
 
  $('table.questions-list col:not(.col-answers)', qArray).css('width', 'auto');
 
 
      $('table.questions-list thead tr', qArray).append('<th class="answer-text inserted-column-label" /></th>');
      $('table.questions-list thead tr th.answer-text.inserted-column-label', qArray).css('width','40%');
 
    $('tr.answers-list', qArray).each(function(i) {
      $(this).append('<td class="answer-item text-item">\
              </td>\
              ');
    });
 
    // Load the column label for the text inputs
    $('.inserted-column-label:eq(0)', qArray).text($('.ls-label-question', qMultiText).text());
    $('.text-item', qArray).append('<label class="ls-label-xs-visibility">'+$('.ls-label-question', qMultiText).text()+'</label>');
 
    // Loop through the multi-short-text sub-questions
    $('li.answer-item', qMultiText).each(function(i) {
      // Move the text inputs into the array
      $('input[type="text"]', this).appendTo($('tr.answers-list:eq('+i+') .text-item', qArray));
    });
 
  });
</script>

File Attachment:

File Name: limesurvey...3857.lss
File Size:25.54 KB


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
More
5 years 5 months ago #195331 by kevinleung
Hi Joffm,

Thank you very much for the help!
May I have the Multiple choice layout?

Kevin
The topic has been locked.
More
5 years 5 months ago #195332 by Joffm
You may use this.
Adapt it to your needs.

www.limesurvey.org/forum/can-i-do-this-w...rray?start=45#170114

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
More
5 years 5 months ago #195375 by kevinleung
Hi Joffm,

Thanks for the information! Really helpful.

Kevin
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose