timer in front page

M

mo

Im trying to design a multiple choice test within the
WebPage with a timer. The timer could be started with a
mouse click so that the user would know when the time
runs out. they cannot work on the test anymore. How do
you put a timer into the WebPage?

please help
 
K

Kevin Spencer

Well, it's got to be a little more complicated than that. For example, while
you could certainly add a timing element to a web page, telling the user
that their time is up isn't going to prevent them from continuing with the
test. One solution would be to use JavaScript to submit the form when the
time runs out, so that the user could not continue. This could be done by
defining a JavaScript function to submit the form, and using another script
to set the time that the first function would be delayed from running.
Example:

<script type="text/javascript"><!--
function submitForm()
{
document.forms[0].submit();
}
setTimeout("submitForm()", 30000);

// --></script>

The JavaScript setTimeout() function takes 2 parameters. The first is the
name of the function to execute. The second is the number of milliseconds to
wait before executing. In my example, it would execute in 30 minutes.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Top