- Posts: 1
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Multiple choice array with a "none of these" exclusion?
- markswarm
- Topic Author
- Offline
- New Member
Less
More
9 years 7 months ago #111407
by markswarm
Multiple choice array with a "none of these" exclusion? was created by markswarm
Hi all, is it at all possible to create a multiple choice array, where if you select "none of these" it excludes anything else within that column?
Been trying to crack this for a while now!
Been trying to crack this for a while now!
The topic has been locked.
- Bigred01
- Offline
- Premium Member
Less
More
- Posts: 88
- Thank you received: 33
9 years 7 months ago #111418
by Bigred01
Replied by Bigred01 on topic Multiple choice array with a "none of these" exclusion?
You can use javascript to do this.
Trigger some script on click of your exclusive option that disables all of the inputs in that column.
Each column td will have a class of 'answer_cell_001', 'answer_cell_002', answer_cell_003.. ect. If someone clicks the exclusive for all answer_cell_001's, just do something like "$('.answer_cell_001').children('input').attr('disabled, true);" and all of the inputs in that column should get disabled. Any input with a status of disabled is ignored when the form is submitted so you wont have to worry about wiping the data for these inputs.
You will have to check to see if the exclusive input is being checked or unchecked though to disable or enable as needed (People should be able to change their mind and without it, all of the inputs would remain disabled).
Now to make it work with the smallest amount of code you will want to set it to trigger on click of any answer option in the exclusive row, find out what 'answer_cell_XXX' it belongs to and apply the code to all inputs minus the exclusive whos parents also have the same 'answer_cell_XXX' class.
A quick warning. If you select an option on this question type then uncheck it, it leaves a value of 0 in the input so the limesurvey exclusive option has a hole that people can get through. I always work my own check in when the #movenextbtn is clicked then throw up an alert and return false top stop the page if nothing is checked.
(Another way that I haven't gotten around to trying is using multiple choice questions for each column then floating them left so they line up side by side. This way would allow you to use the limesurvey exclusive and mandatory options and will be purely css)
This is how I have been adding exclusive options, hope this gets you helps you with your issue.
Trigger some script on click of your exclusive option that disables all of the inputs in that column.
Each column td will have a class of 'answer_cell_001', 'answer_cell_002', answer_cell_003.. ect. If someone clicks the exclusive for all answer_cell_001's, just do something like "$('.answer_cell_001').children('input').attr('disabled, true);" and all of the inputs in that column should get disabled. Any input with a status of disabled is ignored when the form is submitted so you wont have to worry about wiping the data for these inputs.
You will have to check to see if the exclusive input is being checked or unchecked though to disable or enable as needed (People should be able to change their mind and without it, all of the inputs would remain disabled).
Now to make it work with the smallest amount of code you will want to set it to trigger on click of any answer option in the exclusive row, find out what 'answer_cell_XXX' it belongs to and apply the code to all inputs minus the exclusive whos parents also have the same 'answer_cell_XXX' class.
A quick warning. If you select an option on this question type then uncheck it, it leaves a value of 0 in the input so the limesurvey exclusive option has a hole that people can get through. I always work my own check in when the #movenextbtn is clicked then throw up an alert and return false top stop the page if nothing is checked.
(Another way that I haven't gotten around to trying is using multiple choice questions for each column then floating them left so they line up side by side. This way would allow you to use the limesurvey exclusive and mandatory options and will be purely css)
This is how I have been adding exclusive options, hope this gets you helps you with your issue.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
9 years 7 months ago #111438
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 Multiple choice array with a "none of these" exclusion?
There is a workaround for this -
manual.limesurvey.org/Workarounds:_Manip..._Excludes_All_Others
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- Bigred01
- Offline
- Premium Member
Less
More
- Posts: 88
- Thank you received: 33
9 years 7 months ago #111450
by Bigred01
Replied by Bigred01 on topic Multiple choice array with a "none of these" exclusion?
A quick warning. If you select an option on this question type then uncheck it, it leaves a value of 0 in the input so the limesurvey exclusive option has a hole that people can get through. I always work my own check in when the #movenextbtn is clicked then throw up an alert and return false top stop the page if nothing is checked.
Sorry, the above is about the limesurvey mandatory and being able to get past these question types if you check then uncheck an option.
Sorry, the above is about the limesurvey mandatory and being able to get past these question types if you check then uncheck an option.
The topic has been locked.
- srocky
- Offline
- New Member
Less
More
- Posts: 13
- Thank you received: 0
9 years 5 months ago #112985
by srocky
Replied by srocky on topic Multiple choice array with a "none of these" exclusion?
Hi all,
(first of all sorry in advance for my english)
I've tried to use a workaround solution of which tpartner mentioned above, but evidently I've messed up something. I don't know what may gone wrong in a copy/paste action, but when I've used this script the last option indeed exclude every previous options in a row, but while answering following subquestions, the previous exclusive checkboxes become unchecked (however database catch those options as checked). Moreover in the last row exclusive are the last two options.
If anybody can tell me what am I doing wrong?
Best regards for all.
(first of all sorry in advance for my english)
I've tried to use a workaround solution of which tpartner mentioned above, but evidently I've messed up something. I don't know what may gone wrong in a copy/paste action, but when I've used this script the last option indeed exclude every previous options in a row, but while answering following subquestions, the previous exclusive checkboxes become unchecked (however database catch those options as checked). Moreover in the last row exclusive are the last two options.
If anybody can tell me what am I doing wrong?
Best regards for all.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
9 years 5 months ago #112986
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 Multiple choice array with a "none of these" exclusion?
What LS version?
What template?
.
What template?
.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- srocky
- Offline
- New Member
Less
More
- Posts: 13
- Thank you received: 0
9 years 5 months ago #112987
by srocky
Replied by srocky on topic Multiple choice array with a "none of these" exclusion?
LimeSurvey version: 2.05+ Build 140320
Template: basic (with some graphical changes).
Meybe the fact that I'm using XAMPP (not physical server) may have significance?
Thanks in advance for help.
Template: basic (with some graphical changes).
Meybe the fact that I'm using XAMPP (not physical server) may have significance?
Thanks in advance for help.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
9 years 5 months ago #112989
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 Multiple choice array with a "none of these" exclusion?
I have updated the workaround to work with that template -
manual.limesurvey.org/Workarounds:_Manip..._Excludes_All_Others
.
.
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: srocky
The topic has been locked.
- srocky
- Offline
- New Member
Less
More
- Posts: 13
- Thank you received: 0
9 years 5 months ago #112990
by srocky
Replied by srocky on topic Multiple choice array with a "none of these" exclusion?
:woohoo: It works!
Thank you a lot!
Thank you a lot!
The topic has been locked.
- jonsen
- Offline
- Junior Member
Less
More
- Posts: 26
- Thank you received: 3
8 years 11 months ago #118733
by jonsen
Replied by jonsen on topic Multiple choice array with a "none of these" exclusion?
Hi everyone,
I'm just wondering if there isn't a way to do this without additional Javascript. I've tried to use the "exclusive answer" option with "{self.sq_5}" (where rows are a-k, columns 1-5 and column 5 is the "none of these" option). Although this doesn't work because it results in
for EACH row instead of
for row "a" until
for row "k".
But maybe another EM selector would do the trick and just return the row ID, so we could use it like
?
I know the solution with JS is pretty neat, but avoiding editing the template.js too much would be even better and solid for the future. After all, I want my colleagues to do this stuff without messing with my beautifully structured templates...
All the best!
Jonsen
I'm just wondering if there isn't a way to do this without additional Javascript. I've tried to use the "exclusive answer" option with "{self.sq_5}" (where rows are a-k, columns 1-5 and column 5 is the "none of these" option). Although this doesn't work because it results in
Code:
is_empty(111X2222X33333 { E1_a_5, E1_b_5, E1_c_5, E1_d_5, E1_e_5, E1_f_5, E1_g_5, E1_h_5, E1_i_5, E1_j_5, E1_k_5 } .NAOK)
Code:
is_empty(111X2222X33333a5.NAOK)
Code:
is_empty(111X2222X33333k5.NAOK)
But maybe another EM selector would do the trick and just return the row ID, so we could use it like
Code:
Exclusive option: {thisrow.code}5
I know the solution with JS is pretty neat, but avoiding editing the template.js too much would be even better and solid for the future. After all, I want my colleagues to do this stuff without messing with my beautifully structured templates...
All the best!
Jonsen
The topic has been locked.