Check out the LimeSurvey source code on GitHub!

JavaScript Problem with Next-Button

More
5 years 4 months ago #67136 by Veve
Hello everyone,

at the moment I'm doing a questionnaire in 1.91+.
There I need the following programmed:
After a total of 4 Minutes the question field is deactivated.
The next>>> -button is disabled for 3 minutes, after this time it is activated (so that the participants who have finished this question earlier may proceed) and there comes a warning that there is 1 minute left.

I tried programming this feature in JavaScript. However, so far only the text "Warnung" appears however the next>>> button isn't doing anything.


This is the source code I used:


<script language="JavaScript">
<!--
var Aktiv=setTimeout("warnung()",180000);//180000
document.getElementById('movenextbtn').disabled=true;

function warnung(){
document.getElementById("warnung").style.visibility='visible';
document.getElementById('movenextbtn').disabled=false;

}
// End -->
</script



What is wrong with the code? :unsure:
Is it possible to alter the next button!


Thank you very much!!

Veve

Please Log in to join the conversation.

More
5 years 4 months ago - 5 years 4 months ago #67163 by tpartner
I think the main problem is that you are firing the script before all page elements have been loaded.

This script uses jQuery shortcuts and also waits until the page is fully loaded before doing anything.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		$('#movesubmitbtn').attr('disabled', true);
 
		setTimeout(function() {
			warnung();
		}, 180000);
 
		function warnung(){
			$('#warnung').show();
			$('#movesubmitbtn').attr('disabled', false);
		}
	});
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 5 years 4 months ago by tpartner.

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form