Javascript table using variable, returned value, and CSS data
<p>I'm having a problem getting my javascript generated table to input data from my .js file.  I have arrays in seperate .js file:</p>

<pre><code>firstName = new Array();
lastName = new Array();
street = new Array();
city = new Array();
state= new Array();
zip = new Array();
amount = new Array();
date = new Array()


firstName[0]="Nina";
lastName[0]="Largent";
street[0]="88 Regal Lane";
city[0]="Williamsburg";
state[0]="KY";
zip[0]="40769";
amount[0]=125;
date[0]="2011-09-18";


firstName[1]="Mike";
lastName[1]="Hunt";
street[1]="Da404 Barrow Street";
city[1]="London";
state[1]="KY";
zip[1]="40742";
amount[1]=75;
date[1]="2011-09-18";

, etc....
</code></pre>

<p>I have done loops and can document.write the data to the page, but am unable to apply that data where I want it in the local script.</p>

<p>Here is what I have thus far.</p>

<pre><code>&lt;script type="text/javascript"&gt;

    function amountTotal() 
    {
       var total = 0
       for (var i = 0; i&lt;amount.length;i++) 
       {
           total = total + amount[i]     
       }
           {
           return total
           }
    } 
</code></pre>

<p></p>

<p>This returns my total of 5175 that I want to apply to my total cell I thought I should be able to say (document.write("total");), but that doesn't work.  All it does is print the word total in the cell.</p>

<pre><code>  &lt;div id="data_list"&gt;

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

    document.write("&lt;table border='1' rules='rows' cellspacing='0'&gt;");
    document.write("&lt;tr&gt;");
    document.write("&lt;th&gt;Date&lt;/th&gt;&lt;th&gt;Amount&lt;/th&gt;&lt;th&gt;First Name&lt;/th&gt;&lt;th&gt;Last Name&lt;/th&gt;&lt;th&gt;Address&lt;/th&gt;");
    document.write("&lt;/tr&gt;");
    document.write("&lt;/table&gt;");

       var contributors = 0
       for (var i = 0; i &lt;amount.length; i++){

        if (i % 2){
        document.write("&lt;tr&gt;")
    }
        else {
        document.write("&lt;tr class='yellowrow'&gt;")
    }
        document.write("&lt;td&gt;date&lt;/td&gt;&lt;td class='amt'&gt;amount&lt;/td&gt;&lt;td&gt;firstName&lt;/td&gt;&lt;td&gt;lastName&lt;/td&gt;");
        document.write("&lt;td&gt;street&lt;br /&gt;city, state zip&lt;/td&gt;");
        document.write("&lt;/tr&gt;");
}


    &lt;/script&gt;

&lt;/div&gt;

   &lt;div id="totals"&gt;

    &lt;script type="text/javascript"&gt;
    var total = 5175
    document.write("&lt;table border='1' cellspacing='1'&gt;");
    document.write("&lt;tr&gt;");
    document.write("&lt;th id='sumTitle' colspan='2'&gt;");
    document.write("Summary");
    document.write("&lt;/th&gt;");
    document.write("&lt;/tr&gt;");
    document.write("&lt;tr&gt;");
    document.write("&lt;th&gt;Contributors&lt;/th&gt;");
    document.write("&lt;td&gt;contributors&lt;/td&gt;");
    document.write("&lt;/tr&gt;");
    document.write("&lt;tr&gt;");
    document.write("&lt;th&gt;Amount&lt;/th&gt;");
    document.write("&lt;td&gt;$total&lt;/td&gt;");
    document.write("&lt;/tr&gt;");
    document.write("&lt;/table&gt;"); 

    &lt;/script&gt;

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

<p>Any help would be greatly appreciated.  I've been wracking my brain for days on this.</p>
