Update a DIV prior to long running section

  • Thread starter Richard A. DeVenezia
  • Start date
R

Richard A. DeVenezia

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.
 
R

Randy Webb

Richard said:
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;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top