Check out the LimeSurvey source code on GitHub!

Compute value in question

More
5 years 3 months ago #68215 by rafael_ur
Hi everybody
I have a question with multiple choice, P1, in the next question P2, I exclude the answers given in P1 y the rest options show randomly. How could I know if an item is selected in the P2 (I need to load the answer in another question, P3, which is a question of quota)

For instance,

P1 (spontaneous)
1. BMW
2. FIAT
3. RENAULT
4. MERCEDES
5. TOYOTA
It choices 1,3

P2 (random)
1. RENAULT
2. TOYOTA
3. FIAT
It selects 2

P3 (hidden)
YES-NO
Choice FIAT? -> NO

I need to compute FIAT

Thank,
Rafael

Please Log in to join the conversation.

More
5 years 3 months ago #68219 by Mazi
Can't you use conditions for this and maybe have several follow up question displayed depending on the conditions?


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 3 months ago #68226 by rafael_ur
Thank Mazi,

Probably but I have all done I only need to finish this. Is it possible.

Many thank,
Rafael

Please Log in to join the conversation.

More
5 years 3 months ago #68230 by Mazi
I this case I think some custom Javascript to read out the answer and eventually check the yes/no answer option is the only choice.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 3 months ago #68233 by rafael_ur
Yes, I think so but I don't know to do Javascript to read out the answer in the multiple optionc with random.

Rafael.

Please Log in to join the conversation.

More
5 years 3 months ago #68237 by Mazi
Maybe our Javascript expert "tpartner" comes around to have a look...


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 3 months ago #68261 by tpartner
Rafael, are all question on the same page? Can you attach a sample survey?

Cheers,
Tony Partner

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

Please Log in to join the conversation.

More
5 years 3 months ago #68266 by rafael_ur
Hi Tony,
It is question mp2 where I put script.

Many thank,
Rafael
Attachments:

Please Log in to join the conversation.

More
5 years 3 months ago #68305 by tpartner
I'm not clear on what you are trying to do.

Is this correct?

- If "Fiat" is selected in p1 or p2, then mp2 = "Sí"

- Else mp2 = "No"

If so, I think you will need move mp2 to a third group because p2 may be hidden by conditions.

Cheers,
Tony Partner

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

Please Log in to join the conversation.

More
5 years 3 months ago #68318 by rafael_ur
Hi Toni, many thank for you help.

It is correct.
I need everyone to know the brand if not end the interview, so my fee is mp2 and is on the same page, mp2 is quota.
I know when you click on FIAT in P2.
I do not know if I explained.

Thank,
Rafael

Please Log in to join the conversation.

More
5 years 3 months ago #68320 by tpartner
Okay, but I still think you should move mp2 (the quota question) to another group because p2 may not be shown (depending on conditions) and that would leave an empty page shown.

Cheers,
Tony Partner

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

Please Log in to join the conversation.

More
5 years 3 months ago #68326 by rafael_ur
OK Toni,
've changed the thing to the next page shows the blank page buts How I can do to jump to the next page (now empty)?
Sending the file.


Thank,
Rafael
Attachments:

Please Log in to join the conversation.

More
5 years 3 months ago #68327 by tpartner
That makes it easier - we can use {INSERTANS} to get the answers for p1 and p2.

So, in mp2, we add a script that does the following:
- hides the <body> element
- finds if "FIAT" was selected in p1 or p2
- clicks the appropriate radio in mp2
- automatically submits the group
Note that the SGQA values in this script will be different from yours when you import the attached sample survey.
<script type="text/javascript" charset="utf-8"> 
 
	$(document).ready(function(){  	
		// Get p1 and p2 answers
		var p1Ans = "{INSERTANS:35779X963X122822}";  	
		var p2Ans = "{INSERTANS:35779X964X122842}";
 
		// Hide the <body> element so user sees less flash
		$('body').hide();
 
		// Set the radio question
		if (p1Ans == 'FIAT' || p2Ans == 'FIAT') {
			$('.yes-no:eq(0) input.radio:eq(0)').attr('checked', true);	
		}
		else  {
			$('.yes-no:eq(0) input.radio:eq(1)').attr('checked', true);	
		}
 
		// Advance in the survey
		document.limesurvey.move.value = 'movenext';
		document.limesurvey.submit();        
 
	});
</script>

Then in p3, we need to add a small script to allow skipping of the previous hidden group so respondents can go back in the survey:
<script type="text/javascript" charset="utf-8"> 
 
	$(document).ready(function(){ 
 
		// Skip previous group
		$('#moveprevbtn').mousedown(function () { 
			$('#thisstep').val($('#thisstep').val() - 1);
		});
 
	});
</script>

Here is the sample survey with the new code in mp2 and p3:

File Attachment:

File Name: p1p2_v2_TONY.lss
File Size:37 KB

Cheers,
Tony Partner

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

Please Log in to join the conversation.

More
5 years 3 months ago #68328 by rafael_ur
Hi Tony,

Many thanks for your help, good job (I'm going to contribute to support).

Rafael

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form