B
Bundy
Hi
I am trying to write a simple script which counts from 1 to 4.
Problem - It shows 'Start' waits for 2 second then goes straight to 4.
I have just strarted programming so please keep it simple.
Thanks
Bundy
My script
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<script language="JavaScript" type="text/JavaScript">
var abc = 0;
function every_second()
{
for (x=1; x<5; x++)
{
setTimeout("second_function()",2000);
}
}
function second_function()
{
para1.innerText = abc;
abc++;
}
</SCRIPT>
</head>
<body onLoad="every_second();">
<p id="para1" > Start </p>
</body>
</html>
I am trying to write a simple script which counts from 1 to 4.
Problem - It shows 'Start' waits for 2 second then goes straight to 4.
I have just strarted programming so please keep it simple.
Thanks
Bundy
My script
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<script language="JavaScript" type="text/JavaScript">
var abc = 0;
function every_second()
{
for (x=1; x<5; x++)
{
setTimeout("second_function()",2000);
}
}
function second_function()
{
para1.innerText = abc;
abc++;
}
</SCRIPT>
</head>
<body onLoad="every_second();">
<p id="para1" > Start </p>
</body>
</html>