Displaying results of a function in two different types of elements
<p>I'm using this function to total the sum of all values in a column. I would like to have the results display in an input box as well as to the cell that it currently does. I'm just a little stuck on the syntax for mixing the two since one needs to reference a value.</p>

<p>JQuery</p>

<pre><code>$(document).ready(function(){
$('#front_finish, #back_finish').change(function(){
    function tally (selector) {
        $(selector).each(function () {
            var total = 0,
                column = $(this).siblings(selector).andSelf().index(this);
            $(this).parents().prevUntil(':has(' + selector + ')').each(function () {
                total += parseFloat($('td.sum:eq(' + column + ')', this).html()) || 0;
            })
            $(this).html(total);
        });
    }
    tally('td.total');
    });
});
</code></pre>

<p>Input</p>

<pre><code>&lt;input type="text" name="glass_total" id="glass_total" value="0" /&gt;
</code></pre>

<p>Table</p>

<pre><code>&lt;table id="data"&gt;
&lt;tr&gt;
    &lt;th&gt;Finish&lt;/th&gt;
    &lt;th&gt;Pattern&lt;/th&gt;
    &lt;th&gt;Price&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;Front Finish:&lt;/td&gt;
    &lt;td&gt;&lt;span id="front_finish_name"&gt;Mirror&lt;/span&gt;&lt;/td&gt;
    &lt;td class="sum" id="front_finish_price"&gt;15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;Front Pattern:&lt;/td&gt;
    &lt;td&gt;&lt;span id="front_pattern_name"&gt;&lt;/span&gt;&lt;/td&gt;
    &lt;td class="sum" id="front_pattern_price"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;Back Finish:&lt;/td&gt;
    &lt;td&gt;&lt;span id="back_finish_name"&gt;Mirror&lt;/span&gt;&lt;/td&gt;
    &lt;td class="sum" id="back_finish_price"&gt;15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;Back Pattern:&lt;/td&gt;
    &lt;td&gt;&lt;span id="back_pattern_name"&gt;&lt;/span&gt;&lt;/td&gt;
    &lt;td class="sum" id="back_pattern_price"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;th colspan="2" align="right"&gt;Total&lt;/th&gt;
    &lt;td class="total"&gt;&lt;/td&gt;
&lt;/tr&gt;
</code></pre>

<p></p>
