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!

Save a web content each 10 minutes

Status
Not open for further replies.

dandrey

Technical User
Apr 28, 2005
41
CO
Hello, i have a timer in an ASP page but sometime the users forget to push the save button and shutdown the computer and the time is not saved, therefore, i´d like to save the content of the page each 10 minutes without stopping the Javascript counter, how can i do this?

Thanks in advance for your help.
 
You want to look into the AJAX system of doing things.

You can set up a javascript timer that will execute an xmlhttp get to submit the current contents of a form without refreshing the page.

:)

}...the bane of my life!
 
Actually, you could just forcethe form to submit after ten minutes, no AJAX required:
Code:
setTimeout("formName.submit()",10 * 60 * 1000);

Although i am curious as to why your using a timer to keep track of time in the first place. If all you want to do is keep track of time between button pushes, you could just record the server time from each button push and use datediff, no javascript required and it means the time is consistently used from the server. I could think of several ways to game a javascript timer into recording more or less time.

-T

signature.png
 
I am guessing he is wanting an autosave ala gmail where it saves work every few minutes into the drafts folder.
Which is why I suggest the AJAX idea so that the save does not interfere with the user typeing.

}...the bane of my life!
 
Thanks Tarwn, specially you Tarwn
But i would like to know how to do this that you mentioned...

If all you want to do is keep track of time between button pushes, you could just record the server time from each button push and use datediff, no javascript required and it means the time is consistently used from the server.
 
There is a function in ASP called Timer()

You could set a cookie or a session variable to the value of timer.
Then you can check how many seconds the timer has moved on next time a button is clicked.

Code:
<form method="post">
<input type="submit" name="submit" value="Go">
</form>
<%
	if session("start") = "" then
		session("start") = Timer()
	end if
	if request.form("submit")="Go" then
		stagger = Timer()
		response.write(round(stagger - session("start")))  
	end if
%>

}...the bane of my life!
 
or
Code:
<form method="post">
<input type="submit" name="submit" value="Go">
</form>
<%	session.lcid=2057
	if request.cookies("start") = "" then
		response.cookies("start") = time()
	end if
	if request.form("submit")="Go" then
		stagger = time()
		response.write(request.Cookies("start") & " " & stagger & "<br>")
		response.write(datediff("s",request.Cookies("start"),stagger))
	end if
%>

}...the bane of my life!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top