troubleshooting Question

javascript timer over multiple pages

Avatar of newmie22
newmie22Flag for United States of America asked on
JavaScriptPHP
6 Comments1 Solution659 ViewsLast Modified:
I was shown the code below by another expert, and it's worked wonderfully for the parts where i needed to just send the time spent on one page to the database.

However, there are a few pages where it would be easiest that it keeps the time over a number of pages.  I have a learning section for this module/quiz where there are different pages of information they can review before taking the test questions.  I want to know how long they spend looking at those pages, they can move freely between the 5 pages until they click the finished link in the navigation.

Is there a way to accomplish what i'm looking to do? Thanks for any help.
<script>
var currentTime = new Date();
var startTime = currentTime.getTime();

function getElapsedTime()
{
	var endTime = new Date();
	var elapsedTime = (endTime.getTime() - startTime);
	form1.elapsedTime.value = elapsedTime;
}
</script>



<form id=form1 target=_blank>
<input type=hidden name=elapsedTime>
<input type=submit onclick="getElapsedTime()">
</form>
ASKER CERTIFIED SOLUTION
sjklein42

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros