Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

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

Make "Submit" button appear only if people answer "Yes" for a Yes/No question 3 Jahre 3 Monate her #64932

So what I'm trying to do is to have one last page with this question:

You have reached the end of the survey. Please note that once the "SUBMIT" button is clicked, your response is final and will be sent to the management.

Are you sure you want to submit the survey?

- Yes/No answer

The "SUBMIT" button will be disabled when page first load and will only be enabled when the person click "YES".

Is there any way to do this?
Letzte Änderung: 3 Jahre 3 Monate her von sanzo_reload.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Make "Submit" button appear only if people answer "Yes" for a Yes/No question 3 Jahre 3 Monate her #64940

  • atiut
  • atiuts Avatar
  • OFFLINE
  • Senior Lime
  • Beiträge: 76
  • Dank erhalten: 2
  • Karma: 1
Hmm.. you can try to use {SUBMITBUTTON} (see docs.limesurvey.org/The+template+editor&...+LimeSurvey#Keywords), maybe in a hidden/ conditional question.

However you would still need to disable somehow the {NAVIGATOR} button from navigator.pstpl in the theme template. On the last page {NAVIGATOR} becomes a submit button. You could try to remove it from the template then insert it on every page except the last, where you would have a conditioned {SUBMITBUTTON}. Not very elegant though, and there could be some interactions I am missing.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Make "Submit" button appear only if people answer "Yes" for a Yes/No question 3 Jahre 3 Monate her #64948

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4369
  • Dank erhalten: 828
  • Karma: 381
1) Set up your survey to use JavaScript.

2)Add the following script to the source of the Yes/No question.

The script initially disables the Next/Submit button and puts listeners on Yes/No radios to toggle the "disabled" attribute.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		// Initially disable the Next/Submit button
		$('input[type="submit"]').attr('disabled', 'disabled');
 
		// Listeners on Yes/No radios to toggle the Next/Submit button
		$('input.radio[value="Y"]').click(function(){
			$('input[type="submit"]').attr('disabled', '');
		});
		$('input.radio[value="N"]').click(function(){
			$('input[type="submit"]').attr('disabled', 'disabled');
		});
 
	});
 
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: sanzo_reload

Re: Make "Submit" button appear only if people answer "Yes" for a Yes/No question 3 Jahre 3 Monate her #64957

omg! It works!
Thank you so much..
I tried to do this for almost 6 hours, but nothing seems to be working~
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Make "Submit" button appear only if people answer "Yes" for a Yes/No question 1 Jahr 11 Monate her #90412

  • bigbossben
  • bigbossbens Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 4
  • Karma: 0
Hi, thank you so much for that script.
If the code of a question is 15675X876X8765, how do I replace "input.radio" for that question code? I try to replace it and it doesn't work.

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

$(document).ready(function() {

// Initially disable the Next/Submit button
$('input[type="submit"]').attr('disabled', 'disabled');

// Listeners on Yes/No radios to toggle the Next/Submit button
$('15675X876X8765[value="Y"]').click(function(){
$('input[type="submit"]').attr('disabled', '');
});
$('15675X876X8765[value="N"]').click(function(){
$('input[type="submit"]').attr('disabled', 'disabled');
});

});

</script>
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Make "Submit" button appear only if people answer "Yes" for a Yes/No question 1 Jahr 11 Monate her #90414

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4369
  • Dank erhalten: 828
  • Karma: 381
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		// Initially disable the Next/Submit button
		$('input[type="submit"]').attr('disabled', 'disabled');
 
		// Listeners on Yes/No radios to toggle the Next/Submit button
		$('#question8765 input.radio[value="Y"]').click(function(){
			$('input[type="submit"]').attr('disabled', '');
		});
		$('#question8765 input.radio[value="N"]').click(function(){
			$('input[type="submit"]').attr('disabled', 'disabled');
		});
 
	});
 
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: bigbossben

Re: Make "Submit" button appear only if people answer "Yes" for a Yes/No question 1 Jahr 11 Monate her #90415

  • bigbossben
  • bigbossbens Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 4
  • Karma: 0
Thank you so much!!!
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Make "Submit" button appear only if people answer "Yes" for a Yes/No question 1 Jahr 10 Monate her #91559

  • dweisser
  • dweissers Avatar
  • OFFLINE
  • Bronze Donor
  • Beiträge: 205
  • Dank erhalten: 5
  • Karma: 5
The solution looks so simple - but for the life of me I cannot get this to work on my survey.

I have enabled javascript:
Filter HTML for XSS: No

I too have a yes/no question type:
Type: Yes/No

I have copied this code:

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

$(document).ready(function() {

// Initially disable the Next/Submit button
$('input[type="submit"]').attr('disabled', 'disabled');

// Listeners on Yes/No radios to toggle the Next/Submit button
$('input.radio[value="Y"]').click(function(){
$('input[type="submit"]').attr('disabled', '');
});
$('input.radio[value="N"]').click(function(){
$('input[type="submit"]').attr('disabled', 'disabled');
});

});

</script>

I then updated this code to reflect my particular question number.

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

$(document).ready(function() {

// Initially disable the Next/Submit button
$('input[type="submit"]').attr('disabled', 'disabled');

// Listeners on Yes/No radios to toggle the Next/Submit button
$('#question199 input.radio[value="Y"]').click(function(){
$('input[type="submit"]').attr('disabled', '');
});
$('#question199 input.radio[value="N"]').click(function(){
$('input[type="submit"]').attr('disabled', 'disabled');
});

});

</script>

And nothing. Any thoughts? Much appreciated.
David
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Make "Submit" button appear only if people answer "Yes" for a Yes/No question 1 Jahr 10 Monate her #91626

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4369
  • Dank erhalten: 828
  • Karma: 381
LS 2.0 uses button elements instead of inputs for submit. Try this:
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		// Initially disable the Next/Submit button
		$('button[type="submit"]').attr('disabled', 'disabled').addClass('ui-state-disabled');
 
		// Listeners on Yes/No radios to toggle the Next/Submit button
		$('#question199 input.radio[value="Y"]').click(function(){
			$('button[type="submit"]').attr('disabled', '').removeClass('ui-state-disabled');
		});
		$('#question199 input.radio[value="N"]').click(function(){
			$('button[type="submit"]').attr('disabled', 'disabled').addClass('ui-state-disabled');
		});
 
	});
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Make "Submit" button appear only if people answer "Yes" for a Yes/No question 1 Jahr 10 Monate her #91645

  • dweisser
  • dweissers Avatar
  • OFFLINE
  • Bronze Donor
  • Beiträge: 205
  • Dank erhalten: 5
  • Karma: 5
And, once again Tony comes through in the clutch.
Works absolutely perfectly.
I thank you.
- Nebraska David
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.225 Sekunden
Donation Image