Move to 2 previous questions

More
3 years 2 months ago #113207 by Thomas_
Thomas_ created the topic: Move to 2 previous questions
Hi,

I have a conditionnal question that comes when a respondent has entered some value 2 questions before. I want to give the respondent the choice to go back to this question to modifiy her answer or to pursue. The simplest yea to to it is to have the previous button linked not to the immediatly previous question, but to two questions before. Can I do that with a javascript workaround?

The previous button looks like this in html:
<button class="ui-widget ui-state-default ui-corner-all btn btn-primary" accesskey="p" type="button" onclick="javascript:document.limesurvey.move.value = 'moveprev'; $('#limesurvey').submit();" value="Previous" name="move2" id="moveprevbtn" role="button" aria-disabled="false"><span class="ui-button-icon-primary ui-icon ui-icon-triangle-1-w"></span><span class="ui-button-text">Previous</span></button>

Can I change the parameter javascript:document.limesurvey.move.value to give limesurvey a specific question ID I want the respondent to be driven to?

Thanks.

Please Log in to join the conversation.

More
3 years 2 months ago - 3 years 2 months ago #113217 by DenisChenu
DenisChenu replied the topic: Move to 2 previous questions
Hi,

If the question to update is at step 4, (your question is at step 6) try:
<button class="button" name="move" value="4" type="submit" >Change your answer</button>

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .
Last Edit: 3 years 2 months ago by DenisChenu.

Please Log in to join the conversation.

More
3 years 2 months ago #113239 by Thomas_
Thomas_ replied the topic: Move to 2 previous questions
Hi,

Thanks.
Unfortunately, it's not working.
I'm not sure how this move.value parameter works and I haven't been able to find it in the documentation, but I'm sure that if I figure it out I'd be able to do what I want to do. How do I access the current step of the survey?

Best,

Please Log in to join the conversation.

More
3 years 2 months ago #113240 by first
first replied the topic: Move to 2 previous questions
Enable question jumping from the setting and see how clicking on a question code jumps to to the question . May be this will help.

Other way may be showing these question on one page. This way respondent can change answer to the question(two steps before but now showing on same page) without moving back in survey.

Survey Designer and Programmer

Please Log in to join the conversation.

More
3 years 2 months ago #113243 by DenisChenu
DenisChenu replied the topic: Move to 2 previous questions

Thomas_ wrote: ....
Unfortunately, it's not working.
...

We can not help you if you don't give more information.

Can you provide a simple link ?
Try to activate "Show question index / allow jumping" to incremental : then you have your script.

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
3 years 2 months ago #113287 by tpartner
tpartner replied the topic: Move to 2 previous questions
I assume that since you have an onclick attribute you are using LS version 2.0.

So, to modify the "Previous" button to go back 2 steps...

1) Enable the "Show question index / allow jumping" option in survey settings

2) Add this to template.js to hide all of the index stuff (this could also be done with CSS):
$(document).ready(function(){
	// Hide the index stuff
	$('#index').hide();		
	$('.withindex').removeClass('withindex');		
});

3) Add this to the question source where you want the "Previous" behaviour modified:
<script type="text/javascript" charset="utf-8">	
	$(document).ready(function(){
		// Remove the onclick from the "previous" button and bind a new click event
		$("#moveprevbtn").attr('onclick', '').click(function () {
			document.limesurvey.move.value = $('#thisstep').attr('value') - 2; 
			$('#limesurvey').submit();
		});
	});
</script>

Or, perhaps a more user-friendly approach would be instead of messing with the "Previous" button, simply add a new button to the question that takes them back 2 steps. Follow steps 1 and 2 above and then add something like this to the question source:
<p>
	<button id="back2Steps" type="button">Back 2 Steps</button>
</p>
<script type="text/javascript" charset="utf-8">	
	$(document).ready(function(){
		$("#back2Steps").click(function () {
			document.limesurvey.move.value = $('#thisstep').attr('value') - 2; 
			$('#limesurvey').submit();
		});
	});
</script>


.

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.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!