Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set a coldfusion timer 1

Status
Not open for further replies.

hpvic03

Technical User
Aug 2, 2006
89
Ok, I'm trying to set up an application that has a page on it that only gives the user a certain amount of time to submit a form. If the user does not submit the form before the timer runs out, the timer sends the user to a different page. Is there any way to do this with coldfusion?

Help would be greatly appreciated!
 
Use JS. Then when the timer runs out, throw a JS alert. Once the user clicks the "OK" button they are redirected to another page.

_____________________________
Just Imagine.
 
I used this feature for a client's CMS. I'll post the code here tonight. In my case, the users' login session expired after 30 min of inactivity.

_____________________________
Just Imagine.
 
Thanks everybody. Yeah guju, if u could post your code that would great.
 
Add this code snippet between <head></head>
Code:
<!--- START: USING JS TO WARN A USER ABOUT SESSION TIMEOUT --->
[COLOR=red]<cfset sessionTimeout = 30>[/color]
<script language="JavaScript" type="text/javascript">
	<cfoutput>
		var #toScript(([COLOR=blue]sessionTimeout-5[/color])*60*1000,"sTimeout")#
		setTimeout('sessionWarning()', sTimeout);
	
		function sessionWarning() {
		alert('#SESSION.First_Name# #SESSION.Last_Name# your session is about to expire in FIVE MINUTES.');   
		}
	</cfoutput>
</script>
<!--- END: USING JS TO WARN A USER ABOUT SESSION TIMEOUT --->

This portion creates the time limit (in the example above, it is set to 30 minutes)

This portion will subtract 5 minutes before the time so the alert will appear at that instance.

Obviously, this will only work if the user has JS enabled.

Let me know if you run into any issues.


_____________________________
Just Imagine.
 
Hey GUJUm0deL,
I need to do something similar with a form.

I need to set up a form that only allows the user to fill out all fields before the time runs out. It will be a form that has questions to answer. The owner of the form don't want them to have enough time to search the internet for the answers.

Would this code work for a form like that?

 
It can work on any form. You just define the time limit you want the form to be "active". Once the JS timer runs out, you send a JS alert().

Only thing you need to define is how much time is enough time. If you run into any problems, post here and we can help. :)

_____________________________
Just Imagine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top