Re: [SOLVED] - Newbie - Counter script
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: [SOLVED] - Newbie - Counter script

From: Evertjan. <exjxw.hannivoort@interxnl.net>
Date: Tue Jan 10 2006 - 22:06:10 CET

Bundy wrote on 10 jan 2006 in comp.lang.javascript:

>> Try:
>>
>> <script type="text/JavaScript">
>> var abc = 0;
>> function myFunction(){
>> para1.innerHTML = abc++;
>> setTimeout('myFunction()',2000);
>> }
>> </script>
>>
>> <body onLoad='myFunction();'>
>> <p id='para1'>x</p>
>>
>>
>>
>>
>
> Thanks.
>
> To stop script counting to 4 added inside funtion
> if(abc<5)
> {
> setTimeout('myFunction()',2000);
> }
> else
> {
> para1.innerHTML = "finishing counting to four";
> return;
> }
>

The return has no function at the end of a function.

try:

<script type="text/JavaScript">
   var abc = 0;
   function myFunction(){
      if (abc=4){
           para1.innerHTML = "finished counting at four";
           return;
      }
      para1.innerHTML = abc++;
      setTimeout('myFunction()',2000);
   }
</script>

<body onLoad='myFunction();'>
<p id='para1'>x</p>

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Received on Tue Jan 17 17:07:54 2006