- Posts: 9
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Disable specific boxes (=answer options) in a array question (numbers)
- daveintausend
- Topic Author
- Offline
- New Member
Less
More
9 years 5 months ago - 9 years 5 months ago #113832
by daveintausend
Disable specific boxes (=answer options) in a array question (numbers) was created by daveintausend
Hi everyone,
in order to gather data for some Kind of multidimensional scaling I want to set up a Matrix which has the same Labels on both axis and then ask the respondents to state their opinion on how similar the different Labels are. so ofc there's always the case that the same two Labels meet and These boxes should not be able to be assessed -and also one half of the Matrix is the same as the other half. Since explaining this in plain words doesn't really work for me, I hope the following example table may clear things up:
(s. attached Picture aswell)
I've tried addessing the table via Javascript since I don't know of any standard way of doing this.
However, this doesn't seem to work. Any ideas on what I'm doing worng or what might work?
//edit: One additional info: I'm using Dropdown boxes in the Array since there will proabably a 1 to 5 rating
Thanks,
David
in order to gather data for some Kind of multidimensional scaling I want to set up a Matrix which has the same Labels on both axis and then ask the respondents to state their opinion on how similar the different Labels are. so ofc there's always the case that the same two Labels meet and These boxes should not be able to be assessed -and also one half of the Matrix is the same as the other half. Since explaining this in plain words doesn't really work for me, I hope the following example table may clear things up:
x | AAA | BBB | CCC | DDD |
AAA | x | x | x | x |
BBB | ++ | x | x | x |
CCC | + | - | x | x |
DD | -- | ++ | + | x |
(s. attached Picture aswell)
I've tried addessing the table via Javascript since I don't know of any standard way of doing this.
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { $('input[name="79966X1383X175591a_1b"]').attr('disabled', 'disabled'); $('input[name="79966X1383X175592a_2b"]').attr('hidden', 'hidden'); }); </script>
However, this doesn't seem to work. Any ideas on what I'm doing worng or what might work?
//edit: One additional info: I'm using Dropdown boxes in the Array since there will proabably a 1 to 5 rating
Thanks,
David
Attachments:
Last edit: 9 years 5 months ago by daveintausend.
The topic has been locked.
- Ben_V
- Offline
- Platinum Member
Less
More
- Posts: 1128
- Thank you received: 329
9 years 5 months ago #113838
by Ben_V
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Replied by Ben_V on topic Disable specific boxes (=answer options) in a array question (numbers)
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.
- daveintausend
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
9 years 5 months ago - 9 years 5 months ago #113839
by daveintausend
Replied by daveintausend on topic Disable specific boxes (=answer options) in a array question (numbers)
Hi Ben,
I tried this as well but there seems to be nothing happening (my example code is from that post but with my question reference). I thought it's maybe because there might be a difference in adressing a Dropdown Input compared to a text Input? I can get it to work this this example in an Array (text) question, but not in an Array (number) question.
Oh and yes, Javascript itself is working (tested with a simple alert).
Cheers,
David
I tried this as well but there seems to be nothing happening (my example code is from that post but with my question reference). I thought it's maybe because there might be a difference in adressing a Dropdown Input compared to a text Input? I can get it to work this this example in an Array (text) question, but not in an Array (number) question.
Oh and yes, Javascript itself is working (tested with a simple alert).
Cheers,
David
Last edit: 9 years 5 months ago by daveintausend.
The topic has been locked.
- daveintausend
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
9 years 5 months ago - 9 years 5 months ago #113840
by daveintausend
Replied by daveintausend on topic Disable specific boxes (=answer options) in a array question (numbers)
- removed -
Last edit: 9 years 5 months ago by daveintausend.
The topic has been locked.
- Ben_V
- Offline
- Platinum Member
Less
More
- Posts: 1128
- Thank you received: 329
9 years 5 months ago #113841
by Ben_V
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Replied by Ben_V on topic Disable specific boxes (=answer options) in a array question (numbers)
Using dropdown boxes you may have to disable <option> rather than <input> elements
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The following user(s) said Thank You: daveintausend
The topic has been locked.
- daveintausend
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
9 years 5 months ago #113842
by daveintausend
Replied by daveintausend on topic Disable specific boxes (=answer options) in a array question (numbers)
Thanks Benoit, that's what I was looking for.
works like a charm.
Thanks!
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { $('select[name="79966X1383X175591a_b1"]').attr('disabled', 'disabled'); $('select[name="79966X1383X175592a_b2"]').attr('disabled', 'disabled'); }); </script>
works like a charm.
Thanks!
The topic has been locked.
- Ben_V
- Offline
- Platinum Member
Less
More
- Posts: 1128
- Thank you received: 329
9 years 5 months ago - 9 years 5 months ago #113844
by Ben_V
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Replied by Ben_V on topic Disable specific boxes (=answer options) in a array question (numbers)
Remember that you can use {keywords} inside js codes if pasted inside the related question or help text:
79966X1383X175591a_b1
=
{SID}X{GID}X{QID}a_b1
=
{SGQ}ab_1
. =
{SID}X{GID}X{QID}a_b1
=
{SGQ}ab_1
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Last edit: 9 years 5 months ago by Ben_V.
The following user(s) said Thank You: daveintausend
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
9 years 5 months ago - 9 years 5 months ago #113854
by Mazi
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on topic Disable specific boxes (=answer options) in a array question (numbers)
To make it more complex: I recommend removing the duplicates down left of the matrix instead of top right. It is easier to read if you have to make a selection under the headings directly.
This is the code I am using to create this kind of matrix:
This is the code I am using to create this kind of matrix:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question3631'); // Some classes and attributes $('thead tr > *', thisQuestion).each(function(i){ $(this).attr('data-column', i); }); $('tr.subquestions-list', thisQuestion).each(function(i){ $('> *', this).each(function(i){ $(this).attr('data-column', i); }); }); // Hide empty rows and columns $('col', thisQuestion).removeAttr('width'); $('table.subquestions-list thead th', thisQuestion).each(function(i) { if($.trim($(this).text()) == '') { var thisColumn = $(this).attr('data-column'); $('th[data-column="'+thisColumn+'"], td[data-column="'+thisColumn+'"]', thisQuestion).hide(); } }); // Hide unnecessary selects $('tr.subquestions-list:visible', thisQuestion).each(function(i){ $('select:visible:lt('+i+')', this).hide(); $('select:visible:eq(0)', this).hide(); }); // Remove unecessary rows and columns $('tr.subquestions-list:visible:last', thisQuestion).hide(); var firstColumn = $('table.subquestions-list thead th:visible:eq(0)', thisQuestion).attr('data-column'); $('th[data-column="'+firstColumn+'"], td[data-column="'+firstColumn+'"]', thisQuestion).hide(); // Fix up the array row background colours $('tr.subquestions-list:visible', thisQuestion).each(function(i){ $(this).removeClass('array1 array2').addClass('array'+(2-(i%2))); }); }); </script>
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Attachments:
Last edit: 9 years 5 months ago by Mazi.
The following user(s) said Thank You: daveintausend
The topic has been locked.
- daveintausend
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
9 years 5 months ago #113866
by daveintausend
Replied by daveintausend on topic Disable specific boxes (=answer options) in a array question (numbers)
Dear Mazi,
Thanks a lot, that looks quite neat. I understand I have to change the question id in the variable definition, any other adapdations I have to do? So far it's doing nothing :dry:
Really appreciate your help on this!
Thanks
David
Thanks a lot, that looks quite neat. I understand I have to change the question id in the variable definition, any other adapdations I have to do? So far it's doing nothing :dry:
Really appreciate your help on this!
Thanks
David
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
9 years 5 months ago #113867
by Mazi
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on topic Disable specific boxes (=answer options) in a array question (numbers)
Please post a link to an activated sample survey.
Make sure you are using array filter and placeholders for columns and rows.
Make sure you are using array filter and placeholders for columns and rows.
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
- daveintausend
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
9 years 5 months ago #113888
by daveintausend
Replied by daveintausend on topic Disable specific boxes (=answer options) in a array question (numbers)
Hi Mazi,
the sample Survey can be found here: survey.lenze.com/limesurvey/index.php?sid=89417&lang=en
What do you mean by using the Array filter and placeholders for columns/rows? How do I do that?
the sample Survey can be found here: survey.lenze.com/limesurvey/index.php?sid=89417&lang=en
What do you mean by using the Array filter and placeholders for columns/rows? How do I do that?
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
9 years 5 months ago #113890
by Mazi
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on topic Disable specific boxes (=answer options) in a array question (numbers)
1. Which Limesurvey version are you using? Looks like an older one?!
2. Is that the shipped "default" template you are using or an edited template?
2. Is that the shipped "default" template you are using or an edited template?
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.