Need help with javascript counter
Posted: Wed Aug 12, 2009 8:54 pm
Let me state right off the top that I know nothing about javascript.
I am trying to display a single string that says "Record has been added sucessfully" in a table and then have it display for about 5 seconds. After the 5 seconds is up, it will then redirect to another page.
Since I am working with a test file, it does not actually redirect, but simply displays the word "Done!" instead.
The problem I am having is that it seems to be running the timer first and then when the time is up, it displays the word "Done" and then displays the table with the string "Record has been added sucessfully" below it. Everything seems to be going in reverse order.
The code that I am using is:
Can anyone explain to me why it is working this way and how to achieve the intended goal?
Thanks
I am trying to display a single string that says "Record has been added sucessfully" in a table and then have it display for about 5 seconds. After the 5 seconds is up, it will then redirect to another page.
Since I am working with a test file, it does not actually redirect, but simply displays the word "Done!" instead.
The problem I am having is that it seems to be running the timer first and then when the time is up, it displays the word "Done" and then displays the table with the string "Record has been added sucessfully" below it. Everything seems to be going in reverse order.
The code that I am using is:
Code: Select all
<html>
<head>
<title>Timed Display</title>
</head>
<body>
<center>
<table width="300px" height="100" style="border: 1px solid #000000;">
<tr><td align="center">
<script langage="javascript">
<!--
document.write("Record has been added sucessfully");
-->
</script>
</td></tr>
</center>
<script language="javascript">
<!--
var timer=0;
for (count=1; count<=5000; count++){
timer=count; /* I don't need this but examples I looked at had something in here. */
}
document.write("Done!");
-->
</script>
<body>
<html>
Thanks