Hello, I have a question about ASP and Javascript. Thanks in advance.
I would like to show the database table status dynamically through the display of GIF in a web page. The planned method is I use a Javascript function to loop itself every minute to look for any records in the table. If records are found in TABLE, the image source will change to be another GIF (The web page won't refresh itself but is still able to show the latest status of the database table, which is the objective I want). The general codes are shown below. But it won't run successfully. Do you think what's wrong with my codes?
Thank you very much!
-----
<%
Dim adoCon
Dim rsTransaction
Dim strSQL
Set adoCon = Server.CreateObject("ADODB.Connection"
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("test.mdb"
Set rsTransaction = Server.CreateObject("ADODB.Recordset"
%>
<html>
<body>
<img name="status" src="no_record.gif">
<script language="javascript">
nextt();
function nextt() {
<%
strSQL = "SELECT * FROM TABLE"
rsTransaction.Open strSQL, adoCon
if not rsTransaction.eof then
%>
document.images["status"].src = "has_record.gif";
<% end if %>
setTimeout("nextt()", 60000);
}
</script>
</body>
</html>
<%
set adoCon = nothing
rsTransaction.close
set rsTransaction = nothing
%>
I would like to show the database table status dynamically through the display of GIF in a web page. The planned method is I use a Javascript function to loop itself every minute to look for any records in the table. If records are found in TABLE, the image source will change to be another GIF (The web page won't refresh itself but is still able to show the latest status of the database table, which is the objective I want). The general codes are shown below. But it won't run successfully. Do you think what's wrong with my codes?
Thank you very much!
-----
<%
Dim adoCon
Dim rsTransaction
Dim strSQL
Set adoCon = Server.CreateObject("ADODB.Connection"
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("test.mdb"
Set rsTransaction = Server.CreateObject("ADODB.Recordset"
%>
<html>
<body>
<img name="status" src="no_record.gif">
<script language="javascript">
nextt();
function nextt() {
<%
strSQL = "SELECT * FROM TABLE"
rsTransaction.Open strSQL, adoCon
if not rsTransaction.eof then
%>
document.images["status"].src = "has_record.gif";
<% end if %>
setTimeout("nextt()", 60000);
}
</script>
</body>
</html>
<%
set adoCon = nothing
rsTransaction.close
set rsTransaction = nothing
%>