Welcome to the LimeSurvey Community Forum

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

Another disable "next" button question

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 2 months ago #116159 by tpartner
Replied by tpartner on topic Another disable "next" button question
In that case, adding this to the source of one of the questions on every page (group) you want affected should work.

Code:
<script type="text/javascript" charset="utf-8">  
  $(document).ready(function() {
 
    $('#movenextbtn, #movesubmitbtn').hide();
 
    $('input.radio').bind('click', function(e) {
      if($('input.radio:checked').length == $('.radio-list').length) {
        $('#movenextbtn, #movesubmitbtn').show();
      }
    });
 
    });
</script>


Or, if you want to affect every page (group) in the survey, add this to the end of template.js:

Code:
$(document).ready(function() {
 
  $('#movenextbtn, #movesubmitbtn').hide();
 
  $('input.radio').bind('click', function(e) {
    if($('input.radio:checked').length == $('.radio-list').length) {
      $('#movenextbtn, #movesubmitbtn').show();
    }
  });
 
});

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • Taereian_43648
  • Taereian_43648's Avatar
  • Visitor
  • Visitor
9 years 2 months ago #116164 by Taereian_43648
Replied by Taereian_43648 on topic Another disable "next" button question
Thank you so much this scripts are working:)
The only thing is if you go back the next button is hidding until you change a radio button or press it again. Can i fix that somehow?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 2 months ago #116166 by tpartner
Replied by tpartner on topic Another disable "next" button question
Try this:

Code:
<script type="text/javascript" charset="utf-8">  
  $(document).ready(function() {
 
    $('#movenextbtn, #movesubmitbtn').hide();
    if($('input.radio:checked').length == $('.radio-list').length) {
      $('#movenextbtn, #movesubmitbtn').show();
    }
 
    $('input.radio').bind('click', function(e) {
      if($('input.radio:checked').length == $('.radio-list').length) {
        $('#movenextbtn, #movesubmitbtn').show();
      }
    });
 
    });
</script>

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: Taereian_43648
The topic has been locked.
  • Taereian_43648
  • Taereian_43648's Avatar
  • Visitor
  • Visitor
9 years 2 months ago #116168 by Taereian_43648
Replied by Taereian_43648 on topic Another disable "next" button question
Awesome this works:) thanks for that
The only thing that doesn't work is that if a question is hidden by a condition it needs to be pressed as well for showing the next button. Is there a way to apply it just on the visible buttons?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 2 months ago #116171 by tpartner
Replied by tpartner on topic Another disable "next" button question
As I said, this has the potential to get quite complicated. Have a look at the jQuery :visible selector - api.jquery.com/visible-selector/ .

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • Taereian_43648
  • Taereian_43648's Avatar
  • Visitor
  • Visitor
9 years 2 months ago #116175 by Taereian_43648
Replied by Taereian_43648 on topic Another disable "next" button question
Yeah I see your point, is there a way to check if the hidden field is yes.
So I can make all the condition for the hidden fields and show the next button based on its value?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 2 months ago #116179 by tpartner
Replied by tpartner on topic Another disable "next" button question
Sorry, I don't understand the question.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • Taereian_43648
  • Taereian_43648's Avatar
  • Visitor
  • Visitor
9 years 2 months ago - 9 years 2 months ago #116186 by Taereian_43648
Replied by Taereian_43648 on topic Another disable "next" button question
sorry for that, i'm trying something like this:
Code:
<script type="text/javascript" charset="utf-8">  
  $(document).ready(function() {
          // Initially disable the Next/Submit button
               $('#movenextbtn').hide ();
    $('hidden.radio[value="Y"]').click(function(){
                     $('#movenextbtn').show
 
});
});</script>
 

If a hidden radio is Y show the next Button.
Last edit: 9 years 2 months ago by Taereian_43648. Reason: mistake
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 2 months ago #116187 by tpartner
Replied by tpartner on topic Another disable "next" button question
I still don't get where you're going with this but there is no jQuery "hidden" element, you would need to target the radio specifically with an ID and you have some syntax errors.

Something like this (of course, replacing "answer11111X22X33A1" with the correct ID):

Code:
<script type="text/javascript" charset="utf-8">  
  $(document).ready(function() {
 
    $('#movenextbtn, #movesubmitbtn').hide();
 
    if($('#answer11111X22X33A1').is(':checked')) {
      $('#movenextbtn, #movesubmitbtn').show();
    }
 
  });
</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.
More
9 years 2 weeks ago - 9 years 2 weeks ago #118213 by samarta
Replied by samarta on topic Another disable "next" button question
Cheers,

I am trying to disable the next button based on a comparison of the values of 2 questions but it simply does not work. (I don't know the correct syntax)

the script is:

<script type="text/javascript" charset="utf-8">
$(document).ready(function() {

$('#movenextbtn').hide();
if(($('#answer858668X1964X50571')- $('#answer858668X1964X50572')) >5')){
$('#movenextbtn').show();
}

});
</script>

The error is in the comparison. I tried if(7>5) and it worked.
Thanks in advance

João
Last edit: 9 years 2 weeks ago by samarta. Reason: incomplete
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 2 weeks ago #118216 by holch
Replied by holch on topic Another disable "next" button question
But 7 is bigger than 5, thus it should show the button. So I guess this is correct behaviour...

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.
More
9 years 2 weeks ago #118227 by samarta
Replied by samarta on topic Another disable "next" button question
Hi,

what i meant is: I've changed the script to
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {

$('#movenextbtn').hide();
if(7>5)
{
$('#movenextbtn').show();
}

});
</script>

And it worked.


My question is if the sintax of the following line is correct:
if(($('#answer858668X1964X50571')- $('#answer858668X1964X50572')) >5'))
{
$('#movenextbtn').show();
}

Because is not working as I expect.



Thanks,

João
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose