Difference between revisions of "Hide Next button in n seconds"
Line 10: | Line 10: | ||
*If it doesn't exist, do nothing, else disable the Next button, set the time out to number of seconds I want to hide the button, then show the button again. | *If it doesn't exist, do nothing, else disable the Next button, set the time out to number of seconds I want to hide the button, then show the button again. | ||
− | == Code == | + | == Code == |
− | + | <file>quest.onInit = function() | |
+ | { | ||
+ | var secsTimeout = 10; | ||
− | + | if ( !document.getElementsByName('next') || document.getElementsByName('next').length == 0 ) | |
+ | { | ||
+ | // next button not available | ||
+ | return; | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | document.getElementsByName('next')[0].style.display='none'; | ||
+ | } | ||
− | + | var timeout = setTimeout("document.getElementsByName('next')[0].style.display='';", secsTimeout*1000); | |
− | } | + | }</file> |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 04:58, 12 February 2009
Challenge
In order to not allow respondent click on the Next button in a period of t
As a questionnaire creator
I want to hide the Next button in some seconds
Solution
- In questionnaire template editor, choose the question I want to hide the Next button, and then go to the Properties - Edit question properties - Language dependent - Select javascript property
- Create a onInit() function.
- In that function, check if the Next button existed.
- If it doesn't exist, do nothing, else disable the Next button, set the time out to number of seconds I want to hide the button, then show the button again.
Code
<file>quest.onInit = function() {
var secsTimeout = 10;
if ( !document.getElementsByName('next') || document.getElementsByName('next').length == 0 ) { // next button not available return; } else { document.getElementsByName('next')[0].style.display='none'; }
var timeout = setTimeout("document.getElementsByName('next')[0].style.display=;", secsTimeout*1000);
}</file>