Welcome to the LimeSurvey Community Forum

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

Automatically proceed to next question after selecting answer

More
3 years 3 days ago #214927 by FSoave
Hello,
I'm not able to have it working:

the structure:
question group:
- question 1 (a video to be watched)
- question 2 (a yes/no question, mandatory)
question 2 only appears when the video in question 1 has finished playing.

I want to make it so that when the user clicks yes or no in question 2, it proceeds to the following question group.

this is the code I have in question 1

Hello,
I'm not able to havw it working:

the structure:
question group:
- question 1 (a video to be watched)
- question 2 (a yes/no question, mandatory)
question 2 only appears when the video has finished playing.

I want to make it so that when the user clicks yes or no it advances to the following question group.

this is the code I have in question 1

<p style="text-align: center;"><span style="font-size:14px;"><strong>Please watch the video.</strong></span></p>
<p> </p>
<video autoplay="autoplay" controls height="350" id="myvideo" widht="500"><source src="video" type="video/mp4" /> browser does not support this</video>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var sID = '{SID}'; //survey
var gID = '{GID}'; // group
var qID = '{QID}'; //question
var qID1 =+qID+1;

// Hide the "Next" button
$('#ls-button-submit').hide();
// Hide question blocks
$('#question'+qID1).hide();

var vid = document.getElementById("myvideo");
vid.volume = 0.7;
vid.onended = function() { //when video ends
// Hide video block
$('#question'+qID).hide();
// Show question block
$('#question'+qID1).show();
} //onended
});
</script>

I tried adding the code you gave to both question 1 and question 2 but nothing happens when the yes/no button is clicked. where exactly should I add it? thanks
The topic has been locked.
More
3 years 2 days ago #214988 by FSoave
I have to add that I am not using the 'radio' but the 'button group'
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 days ago #214989 by holch

I have to add that I am not using the 'radio' but the 'button group'


What is "the button group"? Never heard of that within Limesurvey.

Maybe upload a screenshot, or even better, provide a LSS file of just the relevant questions for this problem (copy your survey, delete everything that is not relevant).

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 days ago - 3 years 2 days ago #214994 by Joffm
forget

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 2 days ago by Joffm.
The topic has been locked.
More
3 years 2 days ago #214996 by FSoave
Hi, sorry. When you create a Yes/No question, under Display you can choose between "Button Group" or "Radio List".
What element do I have to target in js if I am using the buttons instead of radio?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 days ago #215007 by tpartner
In version 3.x, with a Yes/No question using button group, this script will trigger the "Next" button.

Code:
<script type="text/javascript" data-author="Tony Partner">  
  $(document).on('ready pjax:scriptcomplete',function(){
 
    $('#question{QID} :radio').on('change', function(e) {
      $('#ls-button-submit').trigger('click');
    });
  });
</script>

Sam 

File Attachment:

File Name: limesurvey...1446.lss
File Size:17 KB
ple survey attached:

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: DenisChenu, jbresnick, FSoave
The topic has been locked.
More
2 years 10 months ago - 2 years 10 months ago #216610 by jbresnick
This works great! Thanks!
Last edit: 2 years 10 months ago by jbresnick. Reason: changed questions
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose