How to program and calculate multiple subtotal and grandtotal using jquery?
<p>I'm stump figuring out how to do this in jquery, I need to do it without any plug-in. Imagine a shopping cart for books, each change of quantity (using select dropdown) will update the total price, grandtotal and then the hidden input value.</p>

<pre><code>&lt;table&gt;
&lt;tr&gt; 
    &lt;td class="qty"&gt; 
        &lt;select class="item-1"&gt;
        &lt;option value="1"&gt;1&lt;/option&gt;
        &lt;option value="2"&gt;2&lt;/option&gt;
        &lt;option value="3"&gt;3&lt;/option&gt;
        ...
        &lt;/select&gt;
    &lt;/td&gt; 
    &lt;td class="product"&gt; 
        Book 1 
    &lt;/td&gt; 
    &lt;td class="price-item-1"&gt; 
        $20
    &lt;/td&gt; 
    &lt;td class="total-item-1"&gt; 
        $20
    &lt;/td&gt; 
&lt;/tr&gt;
&lt;tr&gt; 
    &lt;td class="qty"&gt; 
        &lt;select class="item-2"&gt;
        &lt;option value="1"&gt;1&lt;/option&gt;
        &lt;option value="2"&gt;2&lt;/option&gt;
        &lt;option value="3"&gt;3&lt;/option&gt;
        ...
        &lt;/select&gt;
    &lt;/td&gt; 
    &lt;td class="product"&gt; 
        Book 2 
    &lt;/td&gt; 
    &lt;td class="price-item-2"&gt; 
        $10
    &lt;/td&gt; 
    &lt;td class="total-item-2"&gt; 
        $10
    &lt;/td&gt; 
&lt;/tr&gt;
...
...
&lt;tr&gt; 
    &lt;td colspan="3" align="right"&gt; 
        &lt;strong&gt;Grand Total:&lt;/strong&gt; 
    &lt;/td&gt; 
    &lt;td class="grandtotal"&gt;
    &lt;/td&gt; 
&lt;/tr&gt; 
&lt;/table&gt;

&lt;input type="hidden" id="qty-item-1" value="0"  /&gt;
&lt;input type="hidden" id="total-item-1" value="0"  /&gt;

&lt;input type="hidden" id="qty-item-2" value="0"  /&gt;
&lt;input type="hidden" id="total-item-2" value="0"  /&gt;
</code></pre>
