Make "Submit" button appear only if people answer "Yes" for a Yes/No question

More
2 weeks 6 days ago #160957 by FaLifeTime
FaLifeTime replied the topic: Make "Submit" button appear only if people answer "Yes" for
Hi,

i tried the script and works perfectly. My situation is that i'm trying to only condition the submit button if a particular YES/NO question "shows up". If its hidden or not, with this code it always gonna wait for the user to response the YES/NO question.

Is there a way to only make this code works if the question is visible?

Thanks and excuses me for my english,
4aLifeTime

Please Log in to join the conversation.

More
2 weeks 6 days ago #160962 by tpartner
tpartner replied the topic: Make "Submit" button appear only if people answer "Yes" for
How is the question hidden? By relevance on this page or by something on previous pages?

If on previous pages, this should work:

<script type="text/javascript" charset="utf-8">		
	$(document).ready(function() {
 
		// Identify this question
		var thisQuestion = $('#question{QID}');
 
		// Initially disable the Next/Submit button
		if($(thisQuestion).is(':visible')) {
			$('#movenextbtn, #movesubmitbtn').prop('disabled', 'true').addClass('ui-state-disabled');
		}
 
		// Listeners on Yes/No radios to toggle the Next/Submit button
		$('input.radio[value="Y"], label[id$="X{QID}Y"]', thisQuestion).click(function(){
			$('#movenextbtn, #movesubmitbtn').prop('disabled', '').removeClass('ui-state-disabled');
		});
		$('input.radio[value="N"], label[id$="X{QID}N"]', thisQuestion).click(function(){
			$('#movenextbtn, #movesubmitbtn').prop('disabled', 'true').addClass('ui-state-disabled');
		});
 
    });
</script>

If dynamically on this page, you will need listeners on whatever questions are showing/hiding this question.

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: FaLifeTime

Please Log in to join the conversation.

More
2 weeks 5 days ago #160983 by FaLifeTime
FaLifeTime replied the topic: Make "Submit" button appear only if people answer "Yes" for
Exactly what i needed. Thanks a lot!

Please Log in to join the conversation.

More
2 weeks 5 days ago #160996 by Joffm
Joffm replied the topic: Make "Submit" button appear only if people answer "Yes" for
Hi, all,
to be honest, I do not understand this question.

Why should anybody insert a question which offers two answer options, but one without any function?

I think of a scenario like "You have to agree to our terms to proceed...."
In this case people are used to tick a checkbox .

So why not just use a mandatory multiple question with one subquestion.

This should cover everything needed.

Except the challenge for Tony to find a way and develop a new script;)


Maybe somebody can explain to me why this approach with "Yes/No", but without possibility to click "No", was the only way.

Best regards
Joffm
Attachments:
The following user(s) said Thank You: LouisGac

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!