Reorder the sub-questions of a multi-select question

More
1 month 3 weeks ago #199883 by raminnaimi
Hello,
I have a question of a multi-select type (specifically using bootstrap buttons). Is there a way for me to change the order they are displayed?

For example, I have QID1 that asks:
What do you like first?
- Car
- Airplane

and later I have QID 2
Which type do you want?
- Honda
- Tesla
- Boeing
- Airbus

I want QID 2 subquestions to be
- Honda, Tesla, Boeing, Airbus if for QID 1 they selected car,
and
- Boeing, Airbus, Honda, Tesla if for QID 1 they selected Airplane.

Can I change the order of a subquestion dynamically (via expression manager or javascript)? The HTML dom for the multi-select bootstrap question is complex and hard to manipulate.

I'm using LimeSurvey v 4.1

Thanks

Please Log in to join the conversation.

LimeSurvey Partners
More
1 month 3 weeks ago #199886 by Joffm
So you do not want to change the order but only display the relevant brands.

You have to use subquestion relevance

Boeing is only displayed if QID1=="your code for airplane"
Tesla is only displayed if QID1=="your code for car"
This you enter in "condition" of your subquestions



Joffm


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

Please Log in to join the conversation.

More
1 month 3 weeks ago #199887 by raminnaimi
Hi
No, I don’t want to hide anything. The order of the sub questions need to change.

Please Log in to join the conversation.

More
1 month 3 weeks ago #199888 by Joffm
Okay,
two options.

1. Use two questions (of course with the same subquestion codes)
a: Honda, Tesla, Boeing, Airbus
b: Boeing, Airbus, Honda, Tesla

2. Use micro-tayloring (maybe a bit more difficult in analyzing stage)
QID2_SQ001: {if(QUID1==1,"Honda","Boeing"}
QID2_SQ002: {if(QUID1==1,"Tesla","Airbus"}
QID2_SQ003: {if(QUID1==1,"Boeing","Honda"}
...

Joffm


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

Please Log in to join the conversation.

More
1 month 2 weeks ago #199892 by tpartner
Can you provide a small sample survey (.lss file) containing only those questions?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com

Please Log in to join the conversation.

More
1 month 2 weeks ago #199893 by Joffm
I was sure you would create a javascript solution.

Joffm


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

Please Log in to join the conversation.

More
1 month 2 weeks ago #199910 by raminnaimi
I've enclosed the sample survey.
Attachments:

Please Log in to join the conversation.

More
1 month 2 weeks ago #199923 by raminnaimi
Thanks for the suggestion. I was looking for a more scalable solution, and one with javascript. I will have more sub-questions so permutation of all the combinations becomes unmanageable and not ideal.

Please Log in to join the conversation.

More
1 month 2 weeks ago #199952 by tpartner
You have attached a single question, not a sample survey (.lss file) as requested.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com

Please Log in to join the conversation.

More
1 month 1 week ago #200559 by raminnaimi
Hello, I was able to solve this. I've enclosed the sample survey that I demonstrated this. The code to switch the order is below. Obviously, it's hardcoded to move specific subquestions in the multiple choice question, but hopefully it'll be helpful for someone to use when they come across this need.
<script type="text/javascript" charset="utf-8">
   $(document).on('ready pjax:complete',function() {
        place_top = "javatbd{SGQ}TOP";
        $("#answer{SID}X{GID}X619CAR").click(function(){
            move_element = "javatbd{SGQ}C2";
            $("#"+move_element).insertAfter("#"+place_top);
            move_element = "javatbd{SGQ}C1";
            $("#"+move_element).insertAfter("#"+place_top);
            console.log ("car!");
        });
 
        $("#answer{SID}X{GID}X619PLANE").click(function(){
            move_element = "javatbd{SGQ}P2";
            $("#"+move_element).insertAfter("#"+place_top);
            move_element = "javatbd{SGQ}P1";
            $("#"+move_element).insertAfter("#"+place_top);
            console.log ("airplane!");
        });
   });
</script>
Attachments:

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now