Object Expected Error When Writting Table Dynamically
<p>I need your help,</p>

<p>I am attempting to write my table dynamically (for later back-end db use) and I am getting an "object expected" error when I click any of the go to buttons after clicking on the "LOAD" button on my page. Theoretically it should work, as I have written my table to the body of the HTML document. I don't see what I am doing wrong here:</p>

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

&lt;html&gt;

&lt;head&gt;

&lt;style type="text/css"&gt;
#mstrWrapper {
        position: relative;
        height: 200px;
        width: 800px;
        border: 1px solid #808080;

        overflow-y: scroll;
        overflow-x: scroll;
        scrollbar-base-color: #DFDFDF;
        scrollbar-arrow-color: #235A81;

}

#mstrTable {
        width: 800px;
        color: #235A81;
        font-family: Arial;
        font-size: 9pt;
        border: 0px;
}

#mstrTable th, #mstrTable td {
        border-bottom: 1px solid #808080;
        border-right: 1px solid #808080;
        padding: 3px;
}

#mstrTable th {
        filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#ffffff", endColorstr="#cdcdcd");
        width: 110px;
        height: 18px;
        border-bottom: 1px solid #808080;
        border-top: 0px;
}

#mstrTable thead tr {
        position: absolute;
        top: expression(this.offsetParent.scrollTop);
}


#mstrTable tbody tr:first-child td {
        padding: 28px 3px 3px 3px;
}
#mstrTable tr.normal td {
    color: #235A81;
    background-color: white;
}
#mstrTable tr.highlighted td {
    color: #FFFFFF;
    background-color: #235A81;
}

&lt;/style&gt;

&lt;/head&gt;

&lt;body&gt;
&lt;div id="mstrWrapper"&gt;&lt;/div&gt;

&lt;script type="text/javascript"&gt;

function writeit() {
var strVar=" &lt;table id='mstrTable' cellspacing=\"0\" cellpadding=\"0\"&gt;";
strVar += "     &lt;thead&gt;";
strVar += "      &lt;tr&gt; ";
strVar += "        &lt;th&gt;File Number&lt;\/th&gt;";
strVar += "        &lt;th&gt;Date1&lt;\/th&gt;";
strVar += "        &lt;th&gt;Date2&lt;\/th&gt;";
strVar += "        &lt;th&gt;Status&lt;\/th&gt;";
strVar += "        &lt;th&gt;Num.&lt;\/th&gt;";
strVar += "      &lt;\/tr&gt;";
strVar += "    &lt;\/thead&gt;";
strVar += "    &lt;tbody&gt;";
strVar += "      &lt;tr&gt; ";
strVar += "        &lt;td&gt;KABC&lt;\/td&gt;";
strVar += "        &lt;td&gt;09\/12\/2002&lt;\/td&gt;";
strVar += "        &lt;td&gt;09\/12\/2002&lt;\/td&gt;";
strVar += "        &lt;td&gt;Submitted&lt;\/td&gt;";
strVar += "        &lt;td&gt;0&lt;\/td&gt;";
strVar += "";
strVar += "      &lt;\/tr&gt;";
strVar += "      &lt;tr&gt; ";
strVar += "        &lt;td&gt;KCBS&lt;\/td&gt;";
strVar += "        &lt;td&gt;09\/11\/2002&lt;\/td&gt;";
strVar += "        &lt;td&gt;09\/11\/2002&lt;\/td&gt;";
strVar += "        &lt;td&gt;Lockdown&lt;\/td&gt;";
strVar += "        &lt;td&gt;2&lt;\/td&gt;";
strVar += "      &lt;\/tr&gt;";
strVar += "";
strVar += "      &lt;tr&gt; ";
strVar += "        &lt;td&gt;WFLA&lt;\/td&gt;";
strVar += "        &lt;td&gt;09\/11\/2002&lt;\/td&gt;";
strVar += "        &lt;td&gt;09\/11\/2002&lt;\/td&gt;";
strVar += "        &lt;td&gt;Submitted&lt;\/td&gt;";
strVar += "        &lt;td&gt;1&lt;\/td&gt;";
strVar += "      &lt;\/tr&gt;";
strVar += "      &lt;tr&gt; ";
strVar += "        &lt;td&gt;WPPP&lt;\/td&gt;";
strVar += "        &lt;td&gt;03\/19\/2003&lt;\/td&gt;";
strVar += "        &lt;td&gt;03\/19\/2003&lt;\/td&gt;";
strVar += "        &lt;td&gt;In-Progress&lt;\/td&gt;";
strVar += "";
strVar += "        &lt;td&gt;0&lt;\/td&gt;";
strVar += "      &lt;\/tr&gt;";
strVar += "      &lt;tr&gt; ";
strVar += "        &lt;td&gt;WRRR&lt;\/td&gt;";
strVar += "        &lt;td&gt;02\/19\/2002&lt;\/td&gt;";
strVar += "        &lt;td&gt;02\/19\/2002&lt;\/td&gt;";
strVar += "        &lt;td&gt;Submitted&lt;\/td&gt;";
strVar += "        &lt;td&gt;5&lt;\/td&gt;";
strVar += "";
strVar += "      &lt;\/tr&gt;";
strVar += "      &lt;tr&gt; ";
strVar += "        &lt;td&gt;WTTT&lt;\/td&gt;";
strVar += "        &lt;td&gt;02\/19\/2002&lt;\/td&gt;";
strVar += "        &lt;td&gt;02\/19\/2002&lt;\/td&gt;";
strVar += "        &lt;td&gt;In-Progress&lt;\/td&gt;";
strVar += "        &lt;td&gt;0&lt;\/td&gt;";
strVar += "      &lt;\/tr&gt;";
strVar += "";
strVar += "      &lt;tr&gt; ";
strVar += "        &lt;td&gt;WYYD&lt;\/td&gt;";
strVar += "        &lt;td&gt;02\/11\/2002&lt;\/td&gt;";
strVar += "        &lt;td&gt;02\/11\/2002&lt;\/td&gt;";
strVar += "        &lt;td&gt;Submitted&lt;\/td&gt;";
strVar += "        &lt;td&gt;7&lt;\/td&gt;";
strVar += "      &lt;\/tr&gt;";
strVar += "      &lt;tr&gt; ";
strVar += "        &lt;td&gt;WRRR&lt;\/td&gt;";
strVar += "";
strVar += "        &lt;td&gt;02\/19\/2002&lt;\/td&gt;";
strVar += "";
strVar += "        &lt;td&gt;02\/19\/2002&lt;\/td&gt;";
strVar += "        &lt;td&gt;Submitted&lt;\/td&gt;";
strVar += "        &lt;td&gt;5&lt;\/td&gt;";
strVar += "      &lt;\/tr&gt;";
strVar += "    &lt;\/tbody&gt;";
strVar += "";
strVar += "    &lt;\/table&gt;";

document.getElementById('mstrWrapper').innerHTML = strVar

var table = document.getElementById("mstrTable");
var thead = table.getElementsByTagName("thead")[0];
var tbody = table.getElementsByTagName("tbody")[0];
var ishigh;

tbody.onclick = function (e) {
  e = e || window.event;
  var td = e.target || e.srcElement; //assumes there are no other elements inside the td
  var row = td.parentNode;
  if (ishigh&amp;&amp;ishigh!=row){
    ishigh.className='';
  }
  row.className = row.className==="highlighted" ? "" : "highlighted";
  ishigh=row;
}

thead.onclick = function (e) {
  e = e || window.event;
  var th = e.target || e.srcElement;  //assumes there are no other elements in the th
  //alert(th.innerHTML);  ### FOR LATER (DB BACK END USE) ###
}
document.onkeydown = function(e){
    e = e || event;
    var code = e.keyCode, rowslim = table.rows.length - 2, newhigh;
    if(code === 38){ //up arraow
        newhigh = rowindex(ishigh) - 2;
        if(!ishigh || newhigh &lt; 0){return GoTo('mstrTable', rowslim);}
        return GoTo('mstrTable', newhigh);
    } else if (code === 40){ //down arrow
        newhigh = rowindex(ishigh);
        if(!ishigh || newhigh &gt; rowslim){return GoTo('mstrTable', 0);}
        return GoTo('mstrTable', newhigh);
    }
}

function GoTo(id,nu){
  var obj=document.getElementById(id),
      trs=obj.getElementsByTagName('TR');
  nu = nu + 1;
  if (trs[nu]){
    if (ishigh&amp;&amp;ishigh!=trs[nu]){
      ishigh.className='';
    }
    trs[nu].className = trs[nu].className=="highlighted" ? "" : "highlighted";
    ishigh=trs[nu];
   }
}

function rowindex(row){
    var rows = table.rows, i = rows.length;
    while(--i &gt; -1){
        if(rows[i] === row){return i;}
    }
}

}//end of nested function
&lt;/script&gt;
&lt;input type="button" name="" value="GoTo 0" onmouseup="GoTo('mstrTable',0);" /&gt;
&lt;input type="button" name="" value="GoTo 1" onmouseup="GoTo('mstrTable',1);" /&gt;
&lt;input type="button" name="" value="GoTo 2" onmouseup="GoTo('mstrTable',2);" /&gt;
&lt;input type="button" name="" value="GoTo 3" onmouseup="GoTo('mstrTable',3);" /&gt;
&lt;br&gt;
&lt;input type="button" value="LOAD" onclick="writeit()"&gt;

&lt;/body&gt;

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