Welcome, Guest
Username: Password: Remember me

TOPIC: Multiple options with comments

Multiple options with comments 3 years 1 month ago #65383

  • Maximilien
  • Maximilien's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 12
  • Karma: 0
Hi everyone,

I have a small issue with a part of my survey :

I have two questions in my survey:
  • The first one is a "Multiple options with comments" ;
  • The second one is a "Table" using the table filter on the first question.

The questions are in separate groups.

I'd like to get in the sub-questions fields of the second question the answers to the first question.

For example :

Question 1 :
What do you drink at breakfast:
Drink 1 : < INPUT FIELD 1 >
Drink 2 : < INPUT FIELD 2 >
Drink 3 : < INPUT FIELD 3 >

Let's say the user puts in the first input field (INPUT FIELD 1) "Coffee" and in the second one (INPUT FIELD 2) "Tea".

Question 2 :
For each drink, do you put sugar in it ?

YesNoDepends
Coffee
Tea


So normally to do that I use {INSERTANS:...} in the sub-question fields of the question 2. But using it here doesn't work, I only get "No answer", and I really don't understand why.

Do you have any idea of how to further investigate ?

Thanks in advance for your help.
Last Edit: 3 years 1 month ago by Maximilien.
The administrator has disabled public write access.

Re: Multiple options with comments 3 years 1 month ago #65400

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4263
  • Thank you received: 801
  • Karma: 367
That appears to be a bug.

Please file a bug report and...

1. Give as much information as possible.

2. Provide step-by-step instructions how to reproduce the problem.

3. Provide a small sample survey demonstrating the problem.

4. Afterwards please post the link to the bugtracker here so we can follow the progress.


In the meantime however, you may be able to work around it by creating a "Multiple short text" question in the same group as the "Multiple options with comments" and using JavaScript to hide it and populate it with the same inputs as the "Multiple options with comments" question. You could then use {INSERTANS} on this hidden question for your labels in group 2.

1) Set up your survey to use JavaScript.

2) Create a Multiple short text question in the same group as the Multiple options with comments. Give this question identical answers and codes as the Multiple options with comments.

3) Add the following script to the source of one of the questions. Replace "MM" with the Multiple options with comments question ID and "HH" with the Multiple short text question ID.

The script first hides the multi-text question. If a change is made to any input in the multi-options question the value is loaded into the corresponding input of the multi-text question.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		var qMultiOptID = MM;
		var qHiddenID = HH;
 
		// 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];
		}
 
		// Hide the hidden question
		$('#question'+qHiddenID+'').hide();
 
		// A listener on the Multiple options inputs
		$('#question'+qMultiOptID+' input.text').change(function(){
			var ansID = $(this).attr('id');
			var tmp2 = ansID.split('X'+qMultiOptID);
			var ansCode = tmp2[1];
			ansCode = ansCode.replace('comment', '');
			$('#answer'+sID+'X'+gID+'X'+qHiddenID+ansCode).val($(this).val());
		});
	});
 
</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.
Last Edit: 3 years 1 month ago by tpartner.
The administrator has disabled public write access.
The following user(s) said Thank You: Maximilien

Re: Multiple options with comments 3 years 1 month ago #65404

  • Maximilien
  • Maximilien's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 12
  • Karma: 0
Thanks for your help, I will try your workaround.

I've just reported a bug in the bugtracker, here it is. (ID is 5455)
The administrator has disabled public write access.

Re: Multiple options with comments 3 years 1 month ago #65423

  • Maximilien
  • Maximilien's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 12
  • Karma: 0
Just to keep you updated : I tested your workaround and it's working fine. Thanks a lot !
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.111 seconds
Donation Image