jquery to loop through each table row and perform math with each row input field
<p>I have the below table</p>

<pre><code>&lt;table class="authors-list" border=0 id="ordertable"&gt;
    &lt;tr&gt;
        &lt;td&gt;Cubic Meters&lt;/td&gt;&lt;td&gt;Cubes per Bundle&lt;/td&gt;&lt;td&gt;Total Bundles&lt;/td&gt;
    &lt;tr&gt;
       &lt;td&gt;&lt;input type="text" name="cubicmeters1" id="cubicmeters1" value="1.38"&gt;&lt;/td&gt;
       &lt;td&gt;&lt;input type="text" name="cubesperbundle1" id="cubesperbundle1" value="1.485"&gt;&lt;/td&gt;
       &lt;td&gt;&lt;input type="text" name="bundles1" id="bundles1"&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
       &lt;td&gt;&lt;input type="text" name="cubicmeters2" id="cubicmeters2" value="1.38"&gt;&lt;/td&gt;
       &lt;td&gt;&lt;input type="text" name="cubesperbundle2" id="cubesperbundle2" value="1.485"&gt;&lt;/td&gt;
       &lt;td&gt;&lt;input type="text" name="bundles2" id="bundles2"&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
       &lt;td&gt;&lt;input type="text" name="cubicmeters3" id="cubicmeters3" value="1.38"&gt;&lt;/td&gt;
       &lt;td&gt;&lt;input type="text" name="cubesperbundle3" id="cubesperbundle3" value="1.485"&gt;&lt;/td&gt;
       &lt;td&gt;&lt;input type="text" name="bundles3" id="bundles3"&gt;&lt;/td&gt;
   &lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p>what I want to do is loop through each table row and perform a math function against two inputs, and populate the result into a third input.</p>

<p>Fiddle is here: <a href="http://jsfiddle.net/ttZtX/1/" rel="nofollow">http://jsfiddle.net/ttZtX/1/</a></p>

<p>So here is my attempt at the jquery:</p>

<pre><code>$("table.authors-list").find('input[name^="cubicmeters1"]').each(function () {
    cubes += +$(this).closest('tr').find('input[name^="cubicmeters"]').val();
    cubesperbundle += +$(this).closest('tr').find('input[name^="cubesperbundle"]').val();
    +$(this).closest('tr').find('input[name^="bundles"]').val((cubes*cubesperbundle).toFixed(2));
});
</code></pre>

<p>This simply produces no result or error and the input is not populated.</p>

<p>To summarize, my requirement is for jquery to loop through each row, multiply <code>cubicmeters</code> by <code>cubesperbundle</code> and populate <code>bundles</code> with the result. </p>

<p>simple enough but I just cant get it right.</p>

<p>Any help would be appreciated.</p>

<p>Thanks in advance...</p>
