"McKirahan" <Ne**@McKirahan .com> wrote in message news:<7NXLb.164 96$xy6.42580@at tbi_s02>...
"Bob" <r.**********@a ttbi.com> wrote in message
news:5f******** *************** **@posting.goog le.com... Below is sample code that illustrates what I'm trying to do. For sake
of brevity I didn't include the properties of buildBtn that determine
what data to request.
The problem is I never see "Processing request" and depending on
server utilization the response can take several seconds to load
leading the users to wonder if the system is working. Unfortunately
getting rid of the users is not an option :) so any help I can get on
making this work is greatly appreciated.
TIA,
Bob
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script type="text/javascript">
// dynamically build button
function buildBtn(val){
function evt(){
results.innerHT ML = '<h2>Processin g request</h2>';
// Use for loop to simulate time it takes to
// get results page from server
for (var i=0; i<1500000; i++)
null;
// display results
results.innerHT ML = "<h2>" + btn.value + " results</h2>";
}
var btn = document.create Element('input' );
btn.type = "button";
btn.value = val;
btn.onclick = evt;
document.body.a ppendChild(btn) ;
}
</script>
</HEAD>
<BODY>
<script type="text/javascript">
var b1 = new buildBtn('butto n 1');
var b2 = new buildBtn('butto n 2');
</script>
<div id="results" />
</BODY>
</HTML>
I don't know why it doesn't work but you could use:
window.status = "Processing request"
instead then set it to blank afterwards.
It also didn't work when I tried toggling the visibility of an animated gif
such as:
http://www.itn.net/gif/style/ua/loading.gif
using this HTML:
<span id="loading" style="visibili ty:hidden">
<img src="http://www.itn.net/gif/style/ua/loading.gif" border="0"
alt="Processing request">
</span>
and this javascript:
loading.style.v isibility = "visible";
and
loading.style.v isibility = "hidden";
a the beggining and end of the "evt()" function.
Your response got me to thinking. I'm trying to update the screen in
the middle of handling an event which probably is the reason why it
doesn't work. What I really need to do is handle the event then
retrieve the info. So I tried splitting "evt" into two function and
using setTimeout to process the loadTbl function. The problem is I'm
not sure how to reference loadTbl.
If I move loadTbl outside of buildBtn it works but then I have other
issues to deal with so I'd rather not do that if I could avoid it. Any
ideas?
function evt(){
results.innerHT ML = '<h2>Processin g request</h2>';
setTimeout(load Tbl, 1); // This line produces an error
}
function loadTbl(){
// Use for loop to simulate time it takes to
// get results page from server
for (var i=0; i<1500000; i++)
null;
// display results
results.innerHT ML = "<h2>" + btn.value + " results</h2>";
}