Typically, I use spans for that:
<span id="spanStatus"> </span>
and then
function setStatus( strMessage )
{
document.getElementById( "spanStatus" ).firstChild.nodeValue
= strMessage;
}
Beautiful idea, I will use it. Can I also use a DIV ? I would prefer.
Same syntax?
Here is my adjusted version. I want to check before submitting.
I undestood the async nature of this call. Therefore I placed the
submission on the callback. Hope is fine.
Here is complete source code of a demo: HTML / AJAX (yours) / ASP.NET
watch out for line breaks
I wait for you comment / suggestion / corrections...
** THANKS a LOT **
-Pam
========== HTML InteractiveReport_Demo.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml" >
<head>
<title>Interactive Report Demo</title>
<style type="text/css" media="screen">
..c1bg{position:absolute;background:#F0FFF0;border-width:1px;border-style

utset;}
..c1fg{position:absolute;border-width:0;color:#000000;background:transparent;text-align:left;font-family:Tahoma;font-size:11px;font-weight:bold;}
..c3bg{position:absolute;background:#FFFFF0;border-width:1px;border-style

utset;}
..c3fg{position:absolute;border-width:0;color:#008000;background:transparent;text-align:left;font-family:Tahoma;font-size:11px;font-weight:bold;}
</style>
</head>
<body>
<script language="javascript" src="Ajax_Javascript.js"></script>
<!--Messenger form to send the information about the clicked cell to
the ASP page which processes the request-->
<form name="form1" method="get" action="ReportProcessor.aspx"
id="form1">
<input type="hidden" name="ClickedElement" id="MessengerInput"
/>
</form>
<!--2 Examples of cells: on click their ID is passed to the ASP page
for processing (Drill Down / Roll Up) -->
<!--Need to place a cell context menu to differentiate between diffent
actions: Drill / Roll /etc.-->
<div id ="16,0" onclick = "Clicked(this)">
<div class=c3bg
style="top:372px;left:127px;width:88px;height:203px;"></div><div
class=c3fg style="top:374px;left:129px;"><table><tr><td width=82px
height=197px valign=middle>Brazil</td></tr></table></div>
</div>
<div id ="5,0" onclick = "Clicked(this)">
<div class=c1bg
style="top:280px;left:127px;width:88px;height:42px;"></div><div
class=c1fg style="top:282px;left:129px;"><table><tr><td width=82px
height=36px valign=middle>Austria</td></tr></table></div>
</div>
<span id="StatusInfo"> </span>
</body>
</html>
================= AJAX Ajax_Javascript.js
// JScript File: Ajax_Javascript.js
//
http://groups.google.it/group/comp.lang.javascript/browse_frm/thread/b3b8fa7bad9223a4?hl=it
//Laurent Bugnion, GalaSoft
function setStatus( strMessage )
{
document.getElementById("StatusInfo").firstChild.nodeValue =
strMessage;
}
var SubmitURL;
function Clicked(MyControl)
{
var CellID = document.getElementById("MessengerInput");
CellID.value = MyControl.id; //value communicated
SubmitURL = CellID.form.action ;
SubmitOnlyIfUrlActive();
}
var oHttp = null;
function SubmitOnlyIfUrlActive()
{
if ( window.XMLHttpRequest )
{
oHttp = new window.XMLHttpRequest();
}
else
{
if ( window.ActiveXObject )
{
oHttp = new window.ActiveXObject("Microsoft.XMLHTTP" );
}
else
{
setStatus("Unsupported Platform");
}
}
if ( !oHttp )
{
setStatus("Error");
}
oHttp.open("HEAD", SubmitURL, true ); // true = async, false = sync
oHttp.onreadystatechange = CallBack
oHttp.send( null );
}
function CallBack()
{
if ( oHttp.readyState == 4 )
{
if ( oHttp.status == 200 )
{
document.form1.submit()
}
else
{
if (oHttp.status == 404)
{
setStatus( SubmitURL + " Not Found");
}
else
{
setStatus("Error: " + oHttp.status );
}
}
}
}
======= ASP.NET ReportProcessor.aspx
Partial Class ReportProcessor
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Me.Page.Request.HttpMethod = "GET" Then
Response.Write(Me.Page.Request.QueryString("ClickedElement") & " was
clicked")
ElseIf Me.Page.Request.HttpMethod = "POST" Then
Response.Write(Me.Page.Request.Form("ClickedElement") & "
was clicked")
Else
Response.Write("Unexpected Method " &
Me.Page.Request.HttpMethod)
End If
End Sub
End Class