Hello all,

I've got a requirement to write a script that checks some condition on the
server, and to display one image if the condition is true, another if the
condition is false.  But I want to update the image every time the condition
changes.  

For now, I'm using a META REFRESH tag so that the CGI script is rerun every
30 seconds.  But this is not a very good solution, as the whole web page
gets redrawn even when nothing has changed.  I've also thought about using
frames, and having one frame that repeatedly refreshes while the rest of the
page stays static.  Again, not a very elegant solution.

Is there some way (perhaps using JavaScript in conjunction with CGI) to
query the server periodically, and only update the image when the condition
changes?  

Here's the relevant excerpt from my code:

#####################################
$GoNogo = "go";    # or "stop" depending on server-side condition
print <<'End of Header';
Content-type: text/html

<html>
<head>
<title>My title here</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Refresh" content="30">
End of Header

#   irrelevant code here

print  <<"End of Javascript";
<script language="javascript" type="text/javascript">

function setStatus()
{
        if ("$GoNogo" != "go")
        {
                document.fgColor = "#660000";
                document.TheImg.src="go.gif";
                document.links[0].href="#";
        }
        else
        {
                document.fgColor = "#006600";
                document.TheImg.src="stop.gif";
                document.links[0].href=$launchUrl;
        }
}
// -->
</script>
</head>
End of Javascript
        
#  irrelevant code here

print <<'End of Body';
<body onLoad="setStatus()">
Top of page here
<center> <a href="#"><img name="TheImg" ></a> </center>
More body text here
</body>
</html>
End of Body

############################################

Thanks in advance for any help!

Jim Bander, Ph.D.
Operations Research Specialist
Norfolk Southern Corporation
One Georgia Center
600 W Peachtree St, NW,  Suite 900
Atlanta, GA 30308
Phone:   404 897-3060    Fax:  404 897-3063     
e-mail:  [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to