Welcome, Guest
Username: Password: Remember me

TOPIC: Using previous Array question responses to set following Array subquestions

Using previous Array question responses to set following Array subquestions 4 years 7 months ago #62531

  • MaLu
  • MaLu's Avatar
  • Offline
  • Junior Lime
  • Posts: 35
  • Karma: 0
Is that the code you're asking for?

www.panel.statista.com/befragung/index.php?sid=64137&lang=de

hide Question (ID 64137)
Last Edit: 4 years 7 months ago by MaLu.
The administrator has disabled public write access.

Using previous Array question responses to set following Array subquestions 4 years 7 months ago #62532

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5410
  • Thank you received: 1154
  • Karma: 479
I think this:
countChecked(714, 756, 761);

Should be:
countChecked(751, 756, 761);
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Using previous Array question responses to set following Array subquestions 4 years 7 months ago #62533

  • MaLu
  • MaLu's Avatar
  • Offline
  • Junior Lime
  • Posts: 35
  • Karma: 0
ah, ok, I did change that but it still doesn't work.
hiding the question and linking the condition with Q2 works. But answering Q1 doesn't check any box in qHidden.

I'm truely sorry for taking that much of your time...
The administrator has disabled public write access.

Using previous Array question responses to set following Array subquestions 4 years 7 months ago #62539

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5410
  • Thank you received: 1154
  • Karma: 479
Don't be sorry, It's what I signed up for :)

Stu's example used answer codes 1, 2, 3. Yours are A1, A2, A3.

So change
$('#question'+q1ID+'td.answer_cell_001').click(function () {
To
$('#question'+q1ID+'td.answer_cell_00A1').click(function () {

And change
$('#question'+q1ID+'td.answer_cell_002', '#question'+q1ID+'td.answer_cell_003').click(function () {
To
$('#question'+q1ID+'td.answer_cell_00A2', '#question'+q1ID+'td.answer_cell_00A3').click(function () {
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Using previous Array question responses to set following Array subquestions 4 years 7 months ago #62548

  • MaLu
  • MaLu's Avatar
  • Offline
  • Junior Lime
  • Posts: 35
  • Karma: 0
Hi Tony,

I did change that as well, unfortunately, without any success in checking or unchecking in qHidden...

I really appreciate your effort!!
The administrator has disabled public write access.

Using previous Array question responses to set following Array subquestions 4 years 7 months ago #62555

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5410
  • Thank you received: 1154
  • Karma: 479
It seems that with all of the edits a couple of spaces were dropped and a couple of extra single quotes were inserted.

Use this:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() { 
 
		// Call the function
		// Params - Q1 ID, Q2 ID, Hidden question ID
		countChecked(751, 756, 761);
 
		function countChecked(q1ID, q2ID, qHiddenID) {
 
			// Hide the hidden question
			$('#question'+qHiddenID+'').hide();
 
			// Find the survey and group IDs
			if($('input#fieldnames').length != 0) {
				var fieldNames = $('input#fieldnames').attr('value');
				var tmp = fieldNames.split('X');
				var sID = tmp[0];
				var gID = tmp[1];
			}
 
			// A listener on the 1st column of Q1 radio buttons 
			$('#question'+q1ID+' td.answer_cell_00A1').click(function () { 
 
				// Uncheck the corresponding option in the hidden question
				var rowID = $(this).parents('tbody:eq(0)').attr('id');
				var tmp2 = rowID.split('X'+q1ID);
				var answerCode = tmp2[1];
				$('#answer'+sID+'X'+gID+'X'+qHiddenID+answerCode).attr('checked', false);
 
				// Fire the conditions function to hide the corresponding row in Q2
				var hiddenInputValue = $('#answer'+sID+'X'+gID+'X'+qHiddenID+answerCode).attr('value');
				var hiddenInputName = $('#answer'+sID+'X'+gID+'X'+qHiddenID+answerCode).attr('name');
				var hiddenInputType = $('#answer'+sID+'X'+gID+'X'+qHiddenID+answerCode).attr('type');
				checkconditions(hiddenInputValue, hiddenInputName, hiddenInputType)
			});
 
			// A listener on the 2nd and 3rd columns of Q1 radio buttons 
			$('#question'+q1ID+' td.answer_cell_00A2, #question'+q1ID+' td.answer_cell_00A3').click(function () { 
 
				// Check the corresponding option in the hidden question
				var rowID = $(this).parents('tbody:eq(0)').attr('id');
				var tmp2 = rowID.split('X'+q1ID);
				var answerCode = tmp2[1];
				$('#answer'+sID+'X'+gID+'X'+qHiddenID+answerCode).attr('checked', true);
 
				// Fire the conditions function to show the corresponding row in Q2
				var hiddenInputValue = $('#answer'+sID+'X'+gID+'X'+qHiddenID+answerCode).attr('value');
				var hiddenInputName = $('#answer'+sID+'X'+gID+'X'+qHiddenID+answerCode).attr('name');
				var hiddenInputType = $('#answer'+sID+'X'+gID+'X'+qHiddenID+answerCode).attr('type');
				checkconditions(hiddenInputValue, hiddenInputName, hiddenInputType)
			});
		}
 
	});
 
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Aw: Re: Using previous Array question responses to set following Array subquestions 4 years 7 months ago #62558

  • MaLu
  • MaLu's Avatar
  • Offline
  • Junior Lime
  • Posts: 35
  • Karma: 0
Thank you so much!! Highly appreciate your support!!
It works perfectly and looks good. I try to modify that example fitting my initial question. Hopefully, I can leave you alone ;)
The administrator has disabled public write access.

Using previous Array question responses to set following Array subquestions 4 years 7 months ago #62655

  • claudio123
  • claudio123's Avatar
  • Offline
  • Junior Lime
  • Posts: 31
  • Thank you received: 1
  • Karma: 0
Hello,

attached you can find an example Tony helped me to make run. My mistake was that I had the question ID of the hidden question in the array filter box of question2, not the question code.
After correcting this the mini survey is corrected now and can be downloaded to be used as an example.
Thanks again Tony!

best regards
Claudio


File Attachment:

File Name: limesurvey...mple.lss
File Size:35 KB
... lost in brackets ...
(I suggest a preview option for posting in the forum)
The administrator has disabled public write access.

Using previous Array question responses to set following Array subquestions 4 years 7 months ago #62668

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5410
  • Thank you received: 1154
  • Karma: 479
No problem Claudio.

It should be noted that if you download and import the survey, the question IDs will be different (they get changed in during the import process). You will need to modify this line with the new IDs for Q1, Q2 and the hidden question:
countChecked(141, 146, 151);
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Using previous Array question responses to set following Array subquestions 4 years 7 months ago #62678

  • claudio123
  • claudio123's Avatar
  • Offline
  • Junior Lime
  • Posts: 31
  • Thank you received: 1
  • Karma: 0
Tony,

do the question IDs always change when newly imported?
This is quite annoying and makes things quite complicated, I think.

Thanks
c.
... lost in brackets ...
(I suggest a preview option for posting in the forum)
Last Edit: 4 years 7 months ago by claudio123.
The administrator has disabled public write access.

Using previous Array question responses to set following Array subquestions 4 years 7 months ago #62681

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5410
  • Thank you received: 1154
  • Karma: 479
Yes, this is always the case. LS needs to generate new group and question IDs because you may already have those IDs in your database from other surveys.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Using previous Array question responses to set following Array subquestions 4 years 7 months ago #62684

  • MaLu
  • MaLu's Avatar
  • Offline
  • Junior Lime
  • Posts: 35
  • Karma: 0
Hi again!

Your help is excellent and highly appreciated. Now I have a slightly different question/problem...

In another question, I'd like to use previous answers to limit subsequent answering options, however, not appearing as a row but as a column. Is that possible as well? Or do you know a workaround for that as well?
Attached you can find a screenshot that might clarify my question…

Thanks a lot!
Marie
Attachments:
The administrator has disabled public write access.

Using previous Array question responses to set following Array subquestions 4 years 7 months ago #62700

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5410
  • Thank you received: 1154
  • Karma: 479
Hmm, tricky, I'll have to give that some thought. Can you attach a short sample survey for me to test?
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Using previous Array question responses to set following Array subquestions 4 years 7 months ago #62712

  • MaLu
  • MaLu's Avatar
  • Offline
  • Junior Lime
  • Posts: 35
  • Karma: 0
Hi Tony,

I activated the test survey I'm using.

www.panel.statista.com/befragung/admin/a...oup&sid=64137&gid=38

survey ID 64137
Question group ID 38

Is that what you're asking for?
Unfortunately, it's in German. In case of any language barrier, let me know, I’ll try to get an English version…

Salut,
Marie
The administrator has disabled public write access.

Using previous Array question responses to set following Array subquestions 4 years 7 months ago #62730

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5410
  • Thank you received: 1154
  • Karma: 479
That survey requires logging in. It would be easier if you could attach an export of a sample survey. That way I wouldn't need to create a survey to test.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.427 seconds