Calling multiple functions with one button
<p>I am trying to call two functions when only the "add" button is clicked.  the problem I am having is that the final four textboxes in the calculate_balances function are not outputting their variables.</p>

<pre><code>var $ = function (id) {
    return document.getElementById(id);
}




// Declare Arrays to store information from Inputs //
var transactions = [];
transactions[0] = []; // holds date
transactions[1] = []; // holds transaction type
transactions[2] = []; // holds amount

// Function to print results to text area //
var update_results = function () {
    var list = ""; // string variable to build output //    
    // check to see if arrays are empty //
    if (transactions[0].length == 0) {
        $("results").value = "";
    } else {
        list = "";
    // for loop to cycle through arrays and build string for textarea output // 
        for (var i = 0; i &lt; transactions[0].length; i++) {
        list += transactions[0][i] + "     " + transactions[1][i] + "      " + transactions[2][i] + "\n";
        }
    // display results //
    $("results").value = list;
    }


}
// function to gather inputs //
var add_transaction = function () {
    $("add").blur();
    transactions[0][transactions[0].length] = $("date").value;
    transactions[1][transactions[1].length] = $("transType").value;
    transactions[2][transactions[2].length] = parseFloat( $("amount").value);
    update_results();
    calculate_balances();


}

// function for Calculations //
 var calculate_balances = function () {

    var startBal = 2000.00;
    var ttlDeposits = 0;
    var ttlWithdrawals = 0;
    var endBal = startBal;

    if (transactions[1][transactions[1].length] == "deposit")
    {
        ttlDeposits += transactions[2][transactions[2].length];
        endBal += ttlDeposits;
    }
    if (transactions[1][i] == "withdrawal")
    {
        ttlWithdrawals += transactions[2][transactions[i]];
        endBal -= ttlWithdrawals;
    } 

    $("balStart").value = parseFloat(startBal);
    $("ttlDeposits").value = parseFloat(ttlDeposits);
    $("ttlWithdrawals").value = parseFloat(ttlWithdrawals);
    $("balEnd").value = parseFloat(endBal);

}  
window.onload = function () {
    $("add").onclick = add_transaction, calculate_balances;
    update_results();
}
</code></pre>

<p>tHank you</p>
