1.

Solve : Javascript Is it possible to change "onclick" to autostart??

Answer»

I have a script that is a counter that keeps track of how much money the city of SF is collecting from parking tickets.  It works just fine with onclick.  However, I would love for it to start counting when the page opens. I would also love it if there could be commas inserted in between every 3rd number.   

The website is www.findingthesweetspot.com, and the counter to which I am referring is at the top right corner of the home page.  There is another site   www.costofwar.com that autostarts and keeps a live count.  This would be the ultimate goal to have a counter like this one, but with different numbers.  Thanks for your help in advance.

Here is the code:

       





var c=959071;
var t;
function timedCount()
{
document.getElementById('txt').value="$102,"+c;
c=c+1;
t=setTimeout("timedCount()",97);
}


Hi,

Just add the onClick code to a javascript tag UNDER the function.


Code: [Select]<div ID="apDiv33"><FORM>
  <input name="BUTTON" type="button" class="style2" style="font-SIZE: 24px; font-weight: bold; color: #F00;" onClick="()" value=".">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="999" type="text" id="txt" style="font-size: 18px; font-weight: bold;" value="" size="11" maxlength="11">
</form></div>


<script type="text/javascript"style="font-size: 34px; font-weight: NORMAL;">
var c=959071;
var t;
function timedCount()
{
document.getElementById('txt').value="$102,"+c;
c=c+1;
t=setTimeout("timedCount()",97);
}
timedCount();
</script>



Discussion

No Comment Found