Disable specific boxes (=answer options) in a array question (numbers)

More
5 years 8 months ago - 5 years 8 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.
<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: 5 years 8 months ago by daveintausend.

Please Log in to join the conversation.

LimeSurvey Partners
More
5 years 8 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)

Please Log in to join the conversation.

More
5 years 8 months ago - 5 years 8 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: 5 years 8 months ago by daveintausend.

Please Log in to join the conversation.

More
5 years 8 months ago - 5 years 8 months ago #113840 by daveintausend
Last edit: 5 years 8 months ago by daveintausend.

Please Log in to join the conversation.

More
5 years 8 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

Please Log in to join the conversation.

More
5 years 8 months ago #113842 by daveintausend
Thanks Benoit, that's what I was looking for.
<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!

Please Log in to join the conversation.

More
5 years 8 months ago - 5 years 8 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: 5 years 8 months ago by Ben_V.
The following user(s) said Thank You: daveintausend

Please Log in to join the conversation.

More
5 years 8 months ago - 5 years 8 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:


<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
Contact: marcel.minke(at)survey-consulting.com
Want to use your survey offline -> www.offlinesurveys.com
Attachments:
Last edit: 5 years 8 months ago by Mazi.
The following user(s) said Thank You: daveintausend

Please Log in to join the conversation.

More
5 years 8 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

Please Log in to join the conversation.

More
5 years 8 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
Contact: marcel.minke(at)survey-consulting.com
Want to use your survey offline -> www.offlinesurveys.com

Please Log in to join the conversation.

More
5 years 8 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?

Please Log in to join the conversation.

More
5 years 8 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
Contact: marcel.minke(at)survey-consulting.com
Want to use your survey offline -> www.offlinesurveys.com

Please Log in to join the conversation.

More
5 years 8 months ago #113891 by daveintausend
1. Version 1.90+ Build 9642 - So Yes, it's an older one but I guess I have to live with that for the Moment

2. Not really sure. Thought this was the Default one since it's named that way in this Installation.


Anyway - don't want to cause too much trouble around here. Your version looks way nicer ofc, but I guess I could also live with the disabled boxes.

Please Log in to join the conversation.

More
5 years 8 months ago #113893 by Mazi
The JS code doesn't work because it searches for the main HTML element enclosing the current question's code. At the later Limesurvey versions, each table or DIV holding the HTML elements of a certain question gets assigned the question ID. Obviously, this doesn't work for the old 1.90 version and thus the code fails.

Time for an update :-)

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com
Want to use your survey offline -> www.offlinesurveys.com

Please Log in to join the conversation.

More
5 years 8 months ago #113894 by daveintausend
Okay, that makes sense :-)
I'll see if our IT guys are willing to update...

Thanks for your time and patience!



David

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now