Javascript: body onload event, variable exists but afterwards, it becomes undefined
<p>Here is the best example that I can create.  The value of the innerHTML appears in the alert triggered by the onload function.  When it hits the document.write, the same innerHTML becomes null.  Any ideas on how to get the innerHTML to appear outside the onload function?  I've tried global variables and even copying the value to hidden inputs and it still comes up null.</p>

<pre><code>&lt;html&gt;

&lt;head&gt;

&lt;script language='javascript'&gt;
 function onload_function() {
  alert(document.getElementById("sample_size").innerHTML);
 }

 document.write("this is a test: " + document.getElementById("sample_size").innerHTML);
&lt;/script&gt;

&lt;/head&gt;

&lt;body onload='onload_function()'&gt;
 &lt;form name='form_test'&gt;
  &lt;table border='0' cellpadding='0' cellspacing='0'&gt;
   &lt;tr&gt;
    &lt;td id='sample_size' style='display:none'&gt;16&lt;/td&gt;
   &lt;/tr&gt;
  &lt;/table&gt;
 &lt;/form&gt;
&lt;/body&gt;

&lt;/html&gt;
</code></pre>
