- Posts: 7
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Reorder the sub-questions of a multi-select question
- raminnaimi
- Topic Author
- Offline
- New Member
Less
More
3 years 10 months ago #199883
by raminnaimi
Reorder the sub-questions of a multi-select question was created 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
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
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12785
- Thank you received: 3940
3 years 10 months ago #199886
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Reorder the sub-questions of a multi-select question
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
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
The topic has been locked.
- raminnaimi
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
3 years 10 months ago #199887
by raminnaimi
Replied by raminnaimi on topic Reorder the sub-questions of a multi-select question
Hi
No, I don’t want to hide anything. The order of the sub questions need to change.
No, I don’t want to hide anything. The order of the sub questions need to change.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12785
- Thank you received: 3940
3 years 10 months ago #199888
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Reorder the sub-questions of a multi-select question
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
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
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10632
- Thank you received: 3697
3 years 10 months ago #199892
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Reorder the sub-questions of a multi-select question
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.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12785
- Thank you received: 3940
3 years 10 months ago #199893
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Reorder the sub-questions of a multi-select question
I was sure you would create a javascript solution.
Joffm
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- raminnaimi
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
3 years 10 months ago #199910
by raminnaimi
Replied by raminnaimi on topic Reorder the sub-questions of a multi-select question
I've enclosed the sample survey.
Attachments:
The topic has been locked.
- raminnaimi
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
3 years 10 months ago #199923
by raminnaimi
Replied by raminnaimi on topic Reorder the sub-questions of a multi-select question
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.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10632
- Thank you received: 3697
3 years 10 months ago #199952
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Reorder the sub-questions of a multi-select question
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.
The topic has been locked.
- raminnaimi
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
3 years 9 months ago #200559
by raminnaimi
Replied by raminnaimi on topic Reorder the sub-questions of a multi-select question
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.
Code:
<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:
The topic has been locked.