Welcome to the LimeSurvey Community Forum

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

Move to 2 previous questions

More
10 years 10 months ago #113207 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.
More
10 years 10 months ago - 10 years 10 months ago #113217 by DenisChenu
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 support - Plugins, theme and development .
I don't answer to private message.
Last edit: 10 years 10 months ago by DenisChenu.
The topic has been locked.
More
10 years 10 months ago #113239 by Thomas_
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
10 years 10 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.
More
10 years 10 months ago #113243 by DenisChenu

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 support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
More
10 years 10 months ago #113287 by tpartner
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.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose