...

View Full Version : adding a timed counter to a web page



equinecaregroup
03-22-2004, 03:08 AM
I would like to add a counter to help stress what I am writing about. I would like the counter to add 1 to the count every 3 seconds.
As in....since you have been reading this (counter goes here)birds have fallen out of trees.

I would like the counter to appear as normal text (different colour) if that is at all possible. Thank You

swmr
03-22-2004, 03:46 AM
something like this?


<html>
<head>
<title>-</title>
<script type="text/JavaScript">
var birds = 2;
window.onload = function update(){
birds++;
setInterval(function(){
document.getElementById("counter").innerHTML = birds++;
}, 3000);}
</script>
<style type="text/css">
#counter{
font-weight:bold;
color:highlight;
}
</style>
</head>
<body>
<p>
Since you have been reading this, <span id="counter">2</span> birds have fallen out of their nest!
</p>
</body>
</html>

equinecaregroup
03-22-2004, 02:29 PM
That is absolutely brilliant!!!! Thank you so much for your help.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum