Subtracting values from multiple input fields
<p>I'm using the following code to take the value of one field, subtract it from the value of another field and display the result.</p>

<pre><code>$(document).ready(function() {  

    var numIn;
    var numOut;
    var total;

    $('#submit').click(function() {
        numIn = $('input.in').val();
        numOut = $('input.out').val();
        total = numIn-numOut;

        $('span').remove();
        $('body').append('&lt;span&gt;&amp;#163;'+total+'&lt;/span&gt;');
        $('span').fadeIn(250);
    });
});
</code></pre>

<p>I want to create a sort of income/expenditure calculator. so my question is, say I had multiple income fields and multiple expenditure fields how would I take the total value from the income fields away from the total value of the expenditure fields.</p>

<p>Here is an example form in case I haven't been clear.</p>

<pre><code>&lt;form&gt;
&lt;input class="in" type="text"&gt;
&lt;input class="in" type="text"&gt;
&lt;input class="in" type="text"&gt;
&lt;input class="in" type="text"&gt;
&lt;input class="out" type="text"&gt;
&lt;input class="out" type="text"&gt;
&lt;input class="out" type="text"&gt;
&lt;input class="out" type="text"&gt;
&lt;input type="submit" id="submit" value="Submit"&gt;
</code></pre>

<p></p>
