Add & Subtract Input Values with Javascript
<p>I need to add and subtract using Javascript. I've been successful at adding all the input fields together, but been unable to subtract that total amount from the first field. I've inserted an example below whereas you would start out with a balance of 1500, then insert in let's say cost of business in which you have 3 fields to do so. As mentioned I can successfully add up all fields, but can't subtract that total amount from the balance and display it right underneath.</p>

<p>Adding Script</p>

<pre><code>&lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
    $(function(){           
        $('input').each(function() {
            $(this).keyup(function(){  
                calculateTotal($(this));
            });
        });
    });

    function calculateTotal(src) {
        var sum = 0;
        var sumtable = src.closest('.sumtable');

        sumtable.find('input').each(function() {
            if(!isNaN(this.value) &amp;&amp; this.value.length!=0) {
                sum += parseFloat(this.value);
            }
        });

        sumtable.find(".total").html(sum.toFixed(2));
    }   
&lt;/script&gt; 
</code></pre>

<p>HTML</p>

<pre><code>&lt;tr&gt;
    &lt;td&gt;
    &lt;font face='Verdana'&gt;
    &lt;input name='amount' size='6' value='1500.00'&gt;&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;table border='0' cellpadding='0' cellspacing='0' width='16%' height='31'  class='sumtable'&gt;
&lt;tr&gt;

    &lt;font face='Verdana' style='font-size: 8pt; font-weight:700'&gt;
    Amount:&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;
    &lt;font face='Verdana'&gt;
    &lt;input name='amount' size='6' &gt;&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;
    &lt;font face='Verdana'&gt;
    &lt;input name='amount' size='6' &gt;&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;
    &lt;font face='Verdana'&gt;
    &lt;input name='select3_amount' size='6' &gt;&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;p align='right'&gt;&lt;b&gt;
&lt;font face='Verdana' size='2'&gt;Total Cost: $ 
&lt;/font&gt;&lt;/b&gt; &lt;/td&gt;
                &lt;td&gt;&lt;b&gt;&lt;font face='Verdana' size='2'&gt;&lt;span class='total'&gt;0&lt;/span&gt;&lt;/font&gt;&lt;/b&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;p align='right'&gt;&lt;b&gt;
&lt;font face='Verdana' size='2'&gt;Total Remaining: $ 
&lt;/font&gt;&lt;/b&gt; &lt;/td&gt;
&lt;td&gt;&lt;b&gt;&lt;font face='Verdana' size='2'&gt;&lt;span class='balance'&gt;0&lt;/span&gt;&lt;/font&gt;&lt;/b&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p>What do I need to add to display the Remaining Balance? </p>
