Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Move to 2 previous questions

  • Thomas_
  • Thomas_'s Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 5 months ago #113207 by Thomas_
Move to 2 previous questions was created by Thomas_
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:
Code:
<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.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 5 months ago - 9 years 5 months ago #113217 by DenisChenu
Replied by DenisChenu on topic Move to 2 previous questions
Hi,

If the question to update is at step 4, (your question is at step 6) try:
Code:
<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 , plugin development .
I don't answer to private message.
Last edit: 9 years 5 months ago by DenisChenu.
The topic has been locked.
  • Thomas_
  • Thomas_'s Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 5 months ago #113239 by Thomas_
Replied by Thomas_ on 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,
The topic has been locked.
More
9 years 5 months ago #113240 by first
Replied by first on 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
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 5 months ago #113243 by DenisChenu
Replied by DenisChenu on 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 , plugin development .
I don't answer to private message.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 5 months ago #113287 by tpartner
Replied by tpartner on 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):
Code:
$(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:
Code:
<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:
Code:
<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.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose