469,950 Members | 1,941 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

Update a DIV prior to long running section

I have a function that will update a divs innerHTML with the result of a
long running loop. I would like to update the div prior to running the loop
so the person knows it is doing something.
i.e.
function doit () {
mydiv.innerHTML = 'working...';
.... long running loop generates html in variable s
mydiv.innerHTML = s
}

Doing things this way I don't see working..., just the results of the loop
after several seconds.
How might I update mydiv prior to running the loop ?

Thanks.

--
Richard A. DeVenezia
Jul 20 '05 #1
1 1352
Richard A. DeVenezia wrote:
I have a function that will update a divs innerHTML with the result of a
long running loop. I would like to update the div prior to running the loop
so the person knows it is doing something.
i.e.
function doit () {
mydiv.innerHTML = 'working...';
Unless you have mydiv defined elsewhere as a reference to an element,
then the above code is IE only.
.... long running loop generates html in variable s
mydiv.innerHTML = s
}

Doing things this way I don't see working..., just the results of the loop
after several seconds.
How might I update mydiv prior to running the loop ?

Thanks.


function doit(){
document.getElementById('mydiv').innerHTML = 'working......';
myTimer = window.setTimeout('realFunction()',1000);
}

function realFunction(){
//long running loop that generates s
document.getElementById('mydiv').innerHTML = s;
}

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Jan van Veldhuizen | last post: by
9 posts views Thread by James Butler | last post: by
4 posts views Thread by Jonathan Upright | last post: by
8 posts views Thread by Zorpiedoman | last post: by
7 posts views Thread by =?Utf-8?B?Sm9obiBTdGFnZ3M=?= | last post: by
9 posts views Thread by Frank Swarbrick | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.