Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: How can I stop the page reloading if mandatory question not answered?

How can I stop the page reloading if mandatory question not answered? 1 Jahr 8 Monate her #89552

  • Melarish
  • Melarishs Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 15
  • Karma: 0
Currently, if the user clicks "next", it reloads the page (and replays the musical stimulus which they are supposed to hear only once). Can I stop it doing that?

I found something in the manual but I'm not sure if this is it. If yes, do I have to put it on every page or just the template for questionpage?
// Interrupt the submit function and validate mandatory questions
			// NOTE: Comment this section out if questions are not mandatory
			$('form#limesurvey').submit(function(){	
				// Override the built-in "disable navigation buttons" feature
				$('#moveprevbtn, #movenextbtn, #movesubmitbtn').attr('disabled', '');
 
				// Loop through all "shown" questions and check for answer
				var answered = 0;
				$.each(shownQuestions, function(i, val){
					if ( $( 'div#' + val + ' input.radio:checked' ).length == 0 ) {
						$( 'div#' + val + '' ).css('color', 'red');
						answered = 1;
					}	
					else {
						$( 'div#' + val + '' ).css('color', '');
					}
				});
				if ( answered == 1 ) {
					alert ( mandatoryMsg );
					return false;
				}	
				else {
					return true;
				}
			});
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Aw: How can I stop the page reloading if mandatory question not answered? 1 Jahr 8 Monate her #89597

  • jelo
  • jelos Avatar
  • OFFLINE
  • Platinum Lime
  • Beiträge: 467
  • Dank erhalten: 52
  • Karma: 16
Since they only should hear the sound stimulus once, why don't you put the sound stimulus on a simple page without any question and ask the mandatory question on the next page?
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: How can I stop the page reloading if mandatory question not answered? 1 Jahr 8 Monate her #89635

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4118
  • Dank erhalten: 760
  • Karma: 346
That code snippet seems to be incomplete.

What are the mandatory question types and how many are there?
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.

Aw: How can I stop the page reloading if mandatory question not answered? 1 Jahr 8 Monate her #89646

  • Melarish
  • Melarishs Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 15
  • Karma: 0
jelo, that would be wayyyyyyy too much clicking because the whole survey consists of musical stimuli.

tpartner, the question type is List (radio) with 5 options. It's one question per question group. The code is from docs.limesurvey.org/Workarounds%3A+Surve...tions+for+LimeSurvey
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Aw: How can I stop the page reloading if mandatory question not answered? 1 Jahr 8 Monate her #89652

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4118
  • Dank erhalten: 760
  • Karma: 346
...the question type is List (radio) with 5 options. It's one question per question group.
Okay, how about hiding the "Next" button until a radio has been clicked? (I am assuming that respondents are not allowed to go backwards in the survey)

1) Set up your survey to use JavaScript.

2) Add the following script to the source of the radio question.

The script hides the "Next" button until a radio has been clicked.
<script type="text/javascript" charset="utf-8">
	$(document).ready(function(){
 
		// Hide the next button
		$('#movenextbtn').hide();
 
		// Show the next button when a radio is clicked
		$('input.radio').click(function(){
			$('#movenextbtn').show();
		});
 
	});
</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.
Letzte Änderung: 1 Jahr 8 Monate her von tpartner.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.146 Sekunden
Donation Image