Welcome to the LimeSurvey Community Forum

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

Disable/Hide Submit Button if No got clicked

  • McTell
  • McTell's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 2 months ago #162566 by McTell
Hey,

I know there are plenty of threads already on this topic, but for some reason the condition for hiding a button (Yes/No Buttons) is not working:

Excerpt for yes:
Code:
$('input.radio[value="Y"]').click(function(){ ...

although it is an input element with the class radio and has a value attribute with "Y" ... Any ideas why this is not working?


What works is that:

Code:
<script type="text/javascript">
 
  $(document).ready(function() {
 
    // Initially disable the Next/Submit button
    $('#movesubmitbtn').hide();
 
    // Listeners on Yes/No radios to toggle the Next/Submit button
    $('#label-answer535778X13268X208195Y').click(function(){
      $('#movesubmitbtn').show();
    });
    $('#label-answer535778X13268X208195N').click(function(){
      $('#movesubmitbtn').hide();
    });
 
  });
 
</script>
 

But since the ids are LimeSurvey generated this approach is not very sustainable...

Any ideas?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 2 months ago #162567 by tpartner
Replied by tpartner on topic Disable/Hide Submit Button if No got clicked
LimeSurvey version?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • McTell
  • McTell's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 2 months ago #162569 by McTell
Version 2.72.5+171121
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 2 months ago #162570 by tpartner
Replied by tpartner on topic Disable/Hide Submit Button if No got clicked
You can use the Expression Manager {SGQ} placeholder to dynamically pipe in the IDs.

Code:
<script type="text/javascript">
 
  $(document).ready(function() {
 
    // Initially disable the Next/Submit button
    $('#movenextbtn, #movesubmitbtn').hide();
 
    // Listeners on Yes/No radios to toggle the Next/Submit button
    $('#label-answer{SGQ}Y').click(function(){
      $('#movenextbtn, #movesubmitbtn').show();
    });
    $('#label-answer{SGQ}N').click(function(){
      $('#movenextbtn, #movesubmitbtn').hide();
    });
 
  });
 
</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.
  • McTell
  • McTell's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 2 months ago #162576 by McTell
Neat! It works. And it’s working great with the property disabled "effect"
Code:
<script type="text/javascript">
 
  $(document).ready(function() {
 
    // Initially disable the Next/Submit button
    $('#movenextbtn, #movesubmitbtn').prop('disabled', true);
 
    // Listeners on Yes/No radios to toggle the Next/Submit button
    $('#label-answer{SGQ}Y').click(function(){
      $('#movenextbtn, #movesubmitbtn').prop('disabled', false);
    });
    $('#label-answer{SGQ}N').click(function(){
      $('#movenextbtn, #movesubmitbtn').prop('disabled', true);
    });
 
  });
 
</script>
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose