Jump to content
Toggle menu
  • 915 articles
  • 3.8K files
  • 30.2K users
  • 279.2K edits
Catglobe Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Hide Next button in n seconds: Difference between revisions

From Catglobe Wiki
Cg van (talk | contribs)
No edit summary
Ā 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
== ChallengeĀ  ==
== ChallengeĀ  ==


In order to not allow respondent click on the Next button in a period of time<br>As a questionnaire creator<br>I want to hide the Next button in some seconds&nbsp;
In order to not allow respondent click on the Next button in a period of time
Ā 
As a questionnaire creator
Ā 
I want to hide the Next button in some seconds&nbsp;
Ā 
== Example ==
[[Image:HideNextButton1.jpg]]
<br>
[[Image:HideNextButton2.jpg]]


== SolutionĀ  ==
== SolutionĀ  ==


*In questionnaire template editor, choose the&nbsp;question&nbsp;I want to hide the Next button,&nbsp;and then&nbsp;go to the Properties - Edit question properties - Language dependent - Select javascript property&nbsp;
*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. Ā 
*Override quest.onInit function. Ā 
*In that function, check if the Next button existed.&nbsp;
*In that function, check if the Next button exists. Ā 
*If it doesn't exist, do nothing, else disable the Next button, set the time&nbsp;out to number of seconds&nbsp;I want to hide the&nbsp;button, then show the button again.&nbsp;&nbsp;
*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.


[[Image:HideNextButton Code.jpg]]
== CodeĀ  ==
== CodeĀ  ==
<source lang="javascript">
<source lang="javascript">
Line 19: Line 29:
return;
return;
document.getElementsByName('next')[0].style.display='none';
document.getElementsByName('next')[0].style.display='none';
setTimeout("document.getElementsByName('next')[0].style.display=", secsTimeout*1000);
setTimeout("document.getElementsByName('next')[0].style.display='';", secsTimeout*1000);
} Ā 
} Ā 
</source>
</source>
== Source ==
Questionnaire Resource Id on cg site: 159730

Latest revision as of 04:58, 2 February 2012

Challenge

In order to not allow respondent click on the Next button in a period of time

As a questionnaire creator

I want to hide the Next button in some secondsĀ 

Example


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
  • Override quest.onInit function.
  • In that function, check if the Next button exists.
  • 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

quest.onInit = function()
{
	var secsTimeout = 10;
	if ( !document.getElementsByName('next') || document.getElementsByName('next').length == 0 ) 
		// next button not available
		return;
	document.getElementsByName('next')[0].style.display='none';
	setTimeout("document.getElementsByName('next')[0].style.display='';", secsTimeout*1000);
}

Source

Questionnaire Resource Id on cg site: 159730