Dynamic Fields - Adding for Total
<p>I have been trying to figure out a way to make this work, but have only gotten as close as "NaN" as a result.</p>

<p>I have the following table:</p>

<pre><code>     &lt;table border="1" class="autoTable"&gt;

     &lt;tr&gt;&lt;td&gt;&lt;input name="description[]" id="description" value="&lt;?php echo $description; ?&gt;" size="55" onKeyPress="return disableEnterKey(event)" /&gt;
    &lt;/td&gt;&lt;td align="center"&gt;&lt;input type="checkbox"  name="stocked[]" id="stocked" value="&lt;?php echo $stocked; ?&gt;" size="5" onKeyPress="return disableEnterKey(event)" /&gt;
    &lt;/td&gt;&lt;td&gt;&lt;input name="quantity[]" id="quantity" value="&lt;?php echo $quantity; ?&gt;" size="5" onKeyPress="return disableEnterKey(event)" /&gt;
    &lt;/td&gt;&lt;td&gt;&lt;input name="partPrice[]" id="partPrice" value="&lt;?php echo $partPrice; ?&gt;" size="10" onKeyPress="return disableEnterKey(event)" /&gt;
    &lt;/td&gt;&lt;td&gt;&lt;input name="hours[]" id="hours" value="&lt;?php echo $hours; ?&gt;" size="10" onKeyPress="return disableEnterKey(event)" /&gt;
    &lt;/td&gt;&lt;td&gt;&lt;select name="rate[]" id="rate" onKeyPress="return disableEnterKey(event)"&gt;
    &lt;?php
        //Connect to mysql db and retrieve the rate options  
    ?&gt;
    &lt;/select&gt;
    &lt;/td&gt;&lt;td&gt;&lt;!--&lt;span class="amount"&gt;&lt;/span&gt;--&gt;&lt;input name="total[]" id="total" size="10" class="amount" onKeyPress="return disableEnterKey(event)" /&gt;
    &lt;/td&gt;&lt;td align="center"&gt;&lt;input type="checkbox" name="approved[]" id="approved" value="&lt;?php echo $approved; ?&gt;" size="10" onKeyPress="return disableEnterKey(event)" /&gt;
    &lt;/td&gt;&lt;td align="center"&gt;&lt;img src="img/plus.png" width="25" height="25" id="addButton" title="Add New Row" class="addRow" /&gt;
    &lt;/td&gt;&lt;td align="center"&gt;&lt;img src="img/x.png" width="25" height="25" id="removeButton" title="Remove Row" class="delRow" /&gt;
    &lt;/td&gt;&lt;/tr&gt;
    &lt;/table&gt;
</code></pre>

<p>What I want to do is have the total field display the quantity x partPrice plus hours x rate (which is pulled form the database and listed in a select).  I prefer to do this dynamically, so that it is updated on-the-fly.  I have the Add and Remove buttons, so we could add as many rows as necessary.</p>

<p>I would also like to have a total at the bottom of the page - but only have that add each row if "approved" is clicked.</p>

<p>What I have been trying to do, at least temporarily is this jquery:</p>

<pre><code>     $('#hours').blur(function() {
        $('tr').each(function(){
            var total = 0;
            total = parseFloat($(this).find('input[name=quantity]').val());
            $(this).find('.amount').val(parseFloat(total));
        });
     });
</code></pre>

<p>This renders the NaN, and I can't quite figure out what I'm doing wrong.  I haven't even progressed to the approve checkbox, or the final total.</p>

<p>Further, if I add a dynamic row before punching numbers into the quantity, price and hours field, NaN will show in each of the totals.  This is likely because I'm not specifying the array and it's just using all fields with class="amount" (which is all the totals).</p>

<p>What I can do, is use my submit button, and it will pull the values for any and all fields, so database entry is not an issue - but calculating the totals dynamically seems to be.</p>

<p>I would appreciate any insight and assistance.  </p>

<p>Thanks</p>
