Welcome to the LimeSurvey Community Forum

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

Combining Array Text with checkboxes

  • 2022needhelp
  • 2022needhelp's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 3 weeks ago #226906 by 2022needhelp
Combining Array Text with checkboxes was created by 2022needhelp
Please help us help you and fill where relevant:
Your LimeSurvey version: 3.22.28
Own server or LimeSurvey hosting: Limesurvey
Survey theme/template: Custom theme that inherits from Bootswatch
==================
Hi all,
I am currently trying to modify a question format for a survey so that the matrix includes array texts aided by an autocomplete and several checkboxes of which at least one (per entry) must be checked in order to move on to the next question. I was able to modify the following forum entry ( forums.limesurvey.org/forum/can-i-do-thi...n-exclusive-checkbox ) to work for our survey and get the output as seen in the screenshot below.
However, now two problems arise: 
1. I would like to make sure that at least one checkbox is clicked in order to continue to the next question 
2.I can't seem to move on to the next question at all when I run the whole survey 
​​​​​​​
Could someone help me achieve this?

Thanks a lot!

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 3 weeks ago #226907 by tpartner
Replied by tpartner on topic Combining Array Text with checkboxes
Can you attach a small sample survey export (.lss file) containing only the relevant question(s)?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • 2022needhelp
  • 2022needhelp's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 3 weeks ago #226913 by 2022needhelp
Replied by 2022needhelp on topic Combining Array Text with checkboxes
yes of course! I've attached it below. The autocomplete worked fine when I tested it as well. 

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 3 weeks ago #226914 by tpartner
Replied by tpartner on topic Combining Array Text with checkboxes
Please always provide a .lss survey export as asked, so the volunteers helping here don't have to waste time figuring out language, creating a survey, etc.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: 2022needhelp

Please Log in to join the conversation.

  • 2022needhelp
  • 2022needhelp's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 3 weeks ago #226915 by 2022needhelp
Replied by 2022needhelp on topic Combining Array Text with checkboxes
Oh apologies - the lss is now uploaded!

Please Log in to join the conversation.

  • 2022needhelp
  • 2022needhelp's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 3 weeks ago #226974 by 2022needhelp
Replied by 2022needhelp on topic Combining Array Text with checkboxes
I added the LSS version - but I had one more follow up question in case someone can help me with this.
I would like to connect the checkboxes available to categories that have been preselected in the question prior ot the checkbox one. E.g. a participant selects the categories: Grammys, Pulitzer, Oscars in question 1 and only checkboxes for those three categories pop up in the array/matrix question 2. Would this be possible?
Thanks again for the help!

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 3 weeks ago #226976 by Joffm
Replied by Joffm on topic Combining Array Text with checkboxes
Hi,
I extended the script for prepending a question of type "array" by adding a third comment and changing some "answer-list" classes to "subquestion-list"
Code:
<script type="text/javascript" data-author="Tony Partner">
 
    $(document).on('ready pjax:scriptcomplete',function(){
 
        // Identify the questions
        var qArrayID = {QID};
        var qArray = $('#question'+qArrayID);
        var qMultiText = qArray.nextAll('.multiple-short-txt:eq(0)');
        var qMultiTextBis = qMultiText.nextAll('.multiple-short-txt:eq(0)');
        var qMultiTextTre = qMultiText.nextAll('.multiple-short-txt:eq(1)');
 
        // Hide the multi-short-text question
        $(qMultiText).hide();
        $(qMultiTextBis).hide();
        $(qMultiTextTre).hide();
 
        // Remove the core column widths
        $('table.questions-list col:not(.col-answers)', qArray).css('width', 'auto');
 
        // Insert the header cells
        $('table.questions-list thead td:eq(0)', qArray).after('<th class="answer-text inserted-column-label" /></th><th class="answer-text-bis inserted-column-label-bis" /></th><th class="answer-text-bis inserted-column-label-tre" /></th>');
        $('.inserted-column-label, .inserted-column-label-bis, .inserted-column-label-tre', qArray).css('width','15%');
 
        // Insert the answer row cells
        $('tr.subquestion-list', qArray).each(function(i) {
            $('.answertext', this).after('<td class="answer-item text-item"></td><td class="answer-item text-item-bis"></td><td class="answer-item text-item-tre"></td>');
        });
 
        // Load the column label for the text inputs
        $('.inserted-column-label:eq(0)', qArray).text($('.ls-label-question', qMultiText).text());
        $('.inserted-column-label-bis:eq(0)', qArray).text($('.ls-label-question', qMultiTextBis).text());
        $('.inserted-column-label-tre:eq(0)', qArray).text($('.ls-label-question', qMultiTextTre).text());
 
 
        // 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.subquestion-list:eq('+i+') .text-item', qArray));
        });
 
        $('li.answer-item', qMultiTextBis).each(function(i) {
            // Move the text inputs into the array
            $('input[type="text"]', this).appendTo($('tr.subquestion-list:eq('+i+') .text-item-bis', qArray));
        });
        $('li.answer-item', qMultiTextTre).each(function(i) {
            // Move the text inputs into the array
            $('input[type="text"]', this).appendTo($('tr.subquestion-list:eq('+i+') .text-item-tre', qArray));
        });
 
 
    });
</script>

The next is to use the plugin "hideEmptyColumn" to only show the selected categories.




Some more styling necessary regarding the column widths (but lack of time)

Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • 2022needhelp
  • 2022needhelp's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 2 weeks ago #227052 by 2022needhelp
Replied by 2022needhelp on topic Combining Array Text with checkboxes
thank you so much! I wanted to try out this code but unfortunately, I still can't move on from the checkbox question to the next bit of the survey and I also haven't managed to make checking at least one box mandatory.

Any suggestions for this?
Thanks!

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 2 weeks ago - 2 years 2 weeks ago #227054 by Joffm
Replied by Joffm on topic Combining Array Text with checkboxes

I still can't move on from the checkbox question to the next bit of the survey 

I do not see any issue here

and I also haven't managed to make checking at least one box mandatory.

Which validation equation did you use?

Attach a lss export.

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 years 2 weeks ago by Joffm.

Please Log in to join the conversation.

More
6 months 1 week ago - 6 months 1 week ago #251317 by Malak_khashoqji
Replied by Malak_khashoqji on topic Combining Array Text with checkboxes
How can I do that but without any code manually ?
it is not working with me
my version
LimeSurvey Cloud   Version 6.3.0
Last edit: 6 months 1 week ago by Malak_khashoqji. Reason: to specify the version

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 1 week ago #251318 by Joffm
Replied by Joffm on topic Combining Array Text with checkboxes
No information about your LimeSurvey version.
No information about the meaning of "it is not working with me".
No information what you exactly did?

How do you think we can help you?

At least you should provide a lss export of a sample survey.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: Malak_khashoqji

Please Log in to join the conversation.

More
6 months 1 week ago #251320 by Malak_khashoqji
Replied by Malak_khashoqji on topic Combining Array Text with checkboxes
I'm a new user to lime survey
the version that I'm using is :
LimeSurvey Cloud Version 6.3.0

What I want Simply is to create an array (with check box and two text field)
(one question survey)
I have no idea where to add the code provided above
is it possible or doable ?

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose