By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,516 Members | 1,135 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,516 IT Pros & Developers. It's quick & easy.

Update a DIV prior to long running section

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.