Change document before a function ends
<p>Is there a way to modify and update a document before a Javascript function has ended? For example (not what I'm actually doing, but close enough):</p>

<pre><code>function longloop(){
    for(var i=0;i&lt;100;i++){
        x = someLengthyFunction();
        document.getElementById('aTable').innerHTML+='&lt;tr&gt;&lt;td&gt;' + x + '&lt;/td&gt;&lt;/tr&gt;';
    }
}
</code></pre>

<p>That function gets called by a button press, and I'd like to update a table as the loop progresses. What I have up there will only show the updated table when the loop has finished.</p>
