Disable/Hide Submit Button if No got clicked

More
8 months 4 days ago #162566 by McTell
McTell created the topic: Disable/Hide Submit Button if No got clicked
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:
$('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:

<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?

Please Log in or Create an account to join the conversation.

More
8 months 4 days ago #162567 by tpartner
tpartner replied the 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.

Please Log in or Create an account to join the conversation.

More
8 months 4 days ago #162569 by McTell
McTell replied the topic: Disable/Hide Submit Button if No got clicked
Version 2.72.5+171121

Please Log in or Create an account to join the conversation.

More
8 months 3 days ago #162570 by tpartner
tpartner replied the topic: Disable/Hide Submit Button if No got clicked
You can use the Expression Manager {SGQ} placeholder to dynamically pipe in the IDs.

<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.

Please Log in or Create an account to join the conversation.

More
8 months 3 days ago #162576 by McTell
McTell replied the topic: Disable/Hide Submit Button if No got clicked
Neat! It works. And it’s working great with the property disabled "effect"
<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>

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!