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
  • daveintausend's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 4 months ago - 9 years 4 months ago #113832 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:

xAAABBBCCCDDD
AAAxxxx
BBB++xxx
CCC+-xx
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
Last edit: 9 years 4 months ago by daveintausend.
The topic has been locked.
More
9 years 4 months ago #113838 by Ben_V
HI,

A valid answer is probably waiting here ;)

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
  • daveintausend's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 4 months ago - 9 years 4 months ago #113839 by daveintausend
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
Last edit: 9 years 4 months ago by daveintausend.
The topic has been locked.
  • daveintausend
  • daveintausend's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 4 months ago - 9 years 4 months ago #113840 by daveintausend
- removed -
Last edit: 9 years 4 months ago by daveintausend.
The topic has been locked.
More
9 years 4 months ago #113841 by Ben_V
Using dropdown boxes you may have to disable <option> rather than <input> elements :unsure:

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
  • daveintausend's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 4 months ago #113842 by daveintausend
Thanks Benoit, that's what I was looking for.
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.
More
9 years 4 months ago - 9 years 4 months ago #113844 by Ben_V
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
.

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 4 months ago by Ben_V.
The following user(s) said Thank You: daveintausend
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
9 years 4 months ago - 9 years 4 months ago #113854 by Mazi
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:


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 4 months ago by Mazi.
The following user(s) said Thank You: daveintausend
The topic has been locked.
  • daveintausend
  • daveintausend's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 4 months ago #113866 by daveintausend
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
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
9 years 4 months ago #113867 by Mazi
Please post a link to an activated sample survey.

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
  • daveintausend's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 4 months ago #113888 by daveintausend
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 topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
9 years 4 months ago #113890 by Mazi
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?

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.

Lime-years ahead

Online-surveys for every purse and purpose