Welcome, Guest
Username: Password: Remember me

TOPIC: JavaScript Problem with Next-Button

JavaScript Problem with Next-Button 2 years 9 months ago #67136

  • Veve
  • Veve's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 6
  • Karma: 0
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
The administrator has disabled public write access.

Re: JavaScript Problem with Next-Button 2 years 9 months ago #67163

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4068
  • Thank you received: 746
  • Karma: 341
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 2 years 9 months ago by tpartner.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.120 seconds
Donation Image