Welcome, Guest
Username: Password: Remember me

TOPIC: Using INSERTANS with other in multiple question

Using INSERTANS with other in multiple question 3 years 6 months ago #61360

  • AndrejL
  • AndrejL's Avatar
  • OFFLINE
  • Bronze Donor
  • Posts: 35
  • Karma: 1
Hi!

I have a little problem which I assumed it would take 5 minutes of my time but as it turned out I can't figure out a solution.

I have 2 multiple questions (Q1, Q2) with other option included. I would like to display other answer in Q2 only if other was answered in Q1.

Btw, Q1 and Q2have different answers.

Ar first I was thinking something like
if ( "{INSERTANS:SIDXGIDXQIDother}" !== "No answer" ) {   $("#javatbdSIDXGIDXQID2").hide();}

But INSERTANS:SIDXGIDXQIDother always has "no answer" regardless if other option was answered or not.

Any ideas how I can do this?

Thanks, Andrej
The administrator has disabled public write access.

Re: Using INSERTANS with other in multiple question 3 years 6 months ago #61413

  • AndrejL
  • AndrejL's Avatar
  • OFFLINE
  • Bronze Donor
  • Posts: 35
  • Karma: 1
I could also solve my problem if I knew how to set a condition regarding answer to other option in previous multiple option question.

So ask Q2 only if answer Other was given at Q1.

Can that be done?
The administrator has disabled public write access.

Re: Using INSERTANS with other in multiple question 3 years 6 months ago #61427

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5425
  • Thank you received: 307
  • Karma: 252
Since there is no entry at the condition ediotr for the "other" option the only solution is to make question Q1 mandatory and set a condition to Q2 which reads:
"Show Q2 IF:
Q1-A1 equals not checked
AND
Q1-A2 equals not checked
AND
Q2-A3 equals not checked
AND
..."

Where Q2-Ax includes all possible answer options.

Please also fill out a feature request at ideas.limesurvey.org/ideatorrent/all_limeSurvey_1/ and propose to include the other field at the condition editor.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: Using INSERTANS with other in multiple question 3 years 6 months ago #61428

  • AndrejL
  • AndrejL's Avatar
  • OFFLINE
  • Bronze Donor
  • Posts: 35
  • Karma: 1
Unfortunately I don't think this will work. It will work only if Other was the only answer given in Q1.

Which is not what I'm trying to do. I would like to display Q2 if other was answered in Q1 regardless of other answers in Q1.

Is there really no way to determine if other option was checked in multiple question?
The administrator has disabled public write access.

Re: Using INSERTANS with other in multiple question 3 years 6 months ago #61429

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4369
  • Thank you received: 828
  • Karma: 381
But INSERTANS:SIDXGIDXQIDother always has "no answer" regardless if other option was answered or not.
This 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. If possible/helpful please provide screenshots.

4. Afterwards please post the link to the bugtracker here so we can follow the progress.
Is there really no way to determine if other option was checked in multiple question?
If the survey is not in question-by-question mode, you can use JavaScript to populate a hidden question depending on the state of "Other" and then set conditions based on the hidden question.

Otherwise you could set a cookie but that gets a little messy.
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.

Re: Using INSERTANS with other in multiple question 3 years 6 months ago #61446

  • AndrejL
  • AndrejL's Avatar
  • OFFLINE
  • Bronze Donor
  • Posts: 35
  • Karma: 1
Survey is in Q-by-Q mode.

So there is actually no way to do this?
The administrator has disabled public write access.

Re: Using INSERTANS with other in multiple question 3 years 6 months ago #61496

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4369
  • Thank you received: 828
  • Karma: 381
There's almost always a way ;)

We'll go the cookie route:

1) Add the following to the source of the Q1 help text (not the question text because it will mess up the validation). This script will interrupt the submit function and set a cookie depending on the state of the "Other" text input.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
 
		$('form#limesurvey').submit(function(){
 
			if ($('.multiple-opt input.text').val() != '') {
				document.cookie = 'lsOtherChecked=true';
			}
			else {
				document.cookie = 'lsOtherChecked=false';
			}
 
  		});
    });
 
</script>

2) Add the following to the Q2 help text. It will retrieve the cookie and if Q1 "Other" is null, Q2 "Other" is hidden and cleared.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
 
		function getCookie ( cookieName ) {
			var results = document.cookie.match ( '(^|;) ?' + cookieName + '=([^;]*)(;|$)' );
			if ( results )
				return ( unescape ( results[2] ) );
		 	 else
				return null;
		}
 
		var prevOtherChecked = getCookie ('lsOtherChecked');
 
		if(prevOtherChecked == 'false') {
			$('.multiple-opt li[id^="javatbd"]:last').hide();
			$('.multiple-opt li[id^="javatbd"]:last input.text').val('');
			$('.multiple-opt li[id^="javatbd"]:last input.checkbox').attr('checked', false);
		}
    });
 
</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 6 months ago by tpartner.
The administrator has disabled public write access.

Re: Using INSERTANS with other in multiple question 3 years 5 months ago #61542

  • AndrejL
  • AndrejL's Avatar
  • OFFLINE
  • Bronze Donor
  • Posts: 35
  • Karma: 1
Thank you for your help, tpartner.

I tried, but I can't get it to work.

Could someone please check the script and help me with what I am doing wrong.

For the this purpose I created Test survey on demo.limesurvey.org/admin/admin.php

Thanks,

Andrej
The administrator has disabled public write access.

Re: Using INSERTANS with other in multiple question 3 years 5 months ago #61543

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4369
  • Thank you received: 828
  • Karma: 381
A couple of problems;

1) You had the following invalid script in the source of Q1:
<script type="text/javascript">
 
    $(document).ready(function(){
 
{   $("#javatbd38275X170X115976oth").hide();}
 
 
 
 
 
 }
 
</script>

2) That survey is using demo mode with the Xss filter enabled so you can't use JavaScript.

Here is the cleaned up survey:

File Attachment:

File Name: limesurvey_survey_38257.lss
File Size: 20 KB
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.171 seconds
Donation Image