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

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 3 months ago #195856 by Joffm
Hi,

I added your snippet for list-radio questions

You used the correct snippet to insert into "custom.js"?
Code:
$(document).on('ready pjax:scriptcomplete',function(){ 
  $('.list-radio input[type="radio"]').on('click', function() {
    $('#ls-button-submit').trigger('click');
  });
});

Any idea what I might be doing wrong?

No. We cannot see what you are doing, unless we see at least your lss export.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
More
5 years 3 months ago #195862 by matanzino
My custom.js looks like this
Code:
/******************
    User custom JS
    ---------------
 
   Put JS-functions for your template here.
   If possible use a closure, or add them to the general Template Object "Template"
*/
 
$(document).on('ready pjax:scriptcomplete',function(){ 
    /**
     * Code included inside this will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute
     * @see https://learn.jquery.com/using-jquery-core/document-ready/
     */
  $('.list-radio input[type="radio"]').on('click', function() {
    $('#ls-button-submit').trigger('click');
  });
});
 

And I attached the lss I am using.
Thank you very much for any help.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 3 months ago #195871 by tpartner
I tested and the code works perfectly for list-radio questions in that survey. Something else in your theme may be introducing JavaScript errors.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
5 years 3 months ago - 5 years 3 months ago #195889 by matanzino
I tried it with a fresh template again, and now it works for me as well.
The only thing I changed in the other template was to replace the favicon.ico and the logo.png files with custom ones (in the template editor, which was the approach I still new from earlier versions).
Now I uploaded the custom brand logo using the theme options within the questionnaire settings and it still works.
Thanks a lot for the feedback!!
Last edit: 5 years 3 months ago by matanzino.
The topic has been locked.
More
4 years 9 months ago #205193 by haroldrio
Hello there, anyone care to help please.

So I tried this code on a radio list question on limesurvey 3.2 presented as one question per page.

However, I changed the theme question to bootstrap buttons and it did not work anymore.

I tried changing the radio (in red) to bootstrap-buttons and still did not work.


<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$('#question{QID} input[type="radio"]').on('click', function() {
$('#ls-button-submit').trigger('click');
});
});
</script>

thank you
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 months ago #214580 by holch
In the question text of Q1.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The topic has been locked.
More
4 years 2 months 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
4 years 2 months 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
4 years 2 months 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).

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 2 months ago - 4 years 2 months ago #214994 by Joffm
forget

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 years 2 months ago by Joffm.
The topic has been locked.
More
4 years 2 months 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
4 years 2 months 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.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose