I want to delay the execution of nextPart() by 3 sec. each time i increments in the following code. What happens is that i increments and I only get one call to nextPart().
What's wrong?
Thanks.
What's wrong?
Thanks.
Code:
<html>
<head>
<script language="JavaScript" type="text/JavaScript">
var i = 0;
</script>
</head>
<body>
</body>
<script language="JavaScript" type="text/JavaScript">
while(i<4) {
i++;
alert("in while loop");
// I want to suspend the program until the 3 sec has passed.
setTimeout("nextPart()", 3*1000);
}
function nextPart() {
document.write("i = " + i );
alert("nextPart reached");
}
</script>
</html>