Welcome to the LimeSurvey Community Forum

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

Hiding 'Next' button if consent not given

  • hliversedge
  • hliversedge's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 2 months ago #104780 by hliversedge
Hiding 'Next' button if consent not given was created by hliversedge
Sorry if this question's already been answered, but I couldn't find it through searching.

I don't have a registration page in my survey because I don't need users to register, but I still want them to confirm that they've read the participant information sheet. I have therefore been trying to put yes/no checkboxes on the welcome page before participants are able to enter the survey.

I used the code from the workaround for the registration page, which obviously inserts the checkboxes with no problem ( manual.limesurvey.org/Workarounds:_Quest...stering_for_a_survey ).

I also found in the forums someone has previously answered how to hide the 'Next' button

<script type="text/javascript" charset="utf-8">

$(document).ready(function() {

$('#movenextbtn').hide();

});

</script>

which, again, obviously does hide the 'Next' button, the problem is that I don't know how to make the first thing affect the second thing--how do I get the 'Next' button to be hidden only until 'Yes' is checked?
The topic has been locked.
More
10 years 2 months ago - 10 years 2 months ago #104784 by Ben_V
Replied by Ben_V on topic Hiding 'Next' button if consent not given
For a YES/NO question,
try the following code:
Code:
<script type="text/javascript">
 
  $(document).ready(function() {
 
    // Initially disable the Next/Submit button
    $('button[type="submit"]').hide();
 
    // Listeners on Yes/No radios to toggle the Next/Submit button
    $('input.radio[value="Y"]').click(function(){
      $('button[type="submit"]').show();
    });
    $('input.radio[value="N"]').click(function(){
       $('button[type="submit"]').hide();
                   alert('please agree or leave')
    });
 
  });
 
</script>

Notes:
1) Remove or edit the prompted alert if unnecesary...
2) If your html element is not a "button" but an "input", look this previous post

.

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Last edit: 10 years 2 months ago by Ben_V.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose