Dynamic Fields - Adding for Total - Each Line
<p>I have a problem I'm hoping someone has come across and can help.  I had a similar question posted (solved), but have had no further help with a new issue, so I thought I'd post with that question (sorry if this is taboo).</p>

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

&lt;td&gt;Description&lt;/td&gt;&lt;td&gt;Stocked&lt;/td&gt;&lt;td&gt;Quantity&lt;/td&gt;&lt;td&gt;Part Price&lt;/td&gt;
&lt;td&gt;Hours&lt;/td&gt;    
&lt;td&gt;Rate Class&lt;/td&gt;&lt;td&gt;Total&lt;/td&gt;&lt;td&gt;Approved&lt;/td&gt;&lt;td&gt;Add New Row&lt;/td&gt;    
&lt;td&gt;Remove Row&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;input name="description[]" id="description" value="&lt;?php echo $description; ?&gt;" size="55" class="numeric add_to_total" 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" class="numeric add_to_total" 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" class="numeric add_to_total quantity" 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" class="numeric add_to_total part" 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" class="numeric add_to_total hours" onKeyPress="return disableEnterKey(event)" /&gt;
&lt;/td&gt;&lt;td&gt;&lt;select name="rate[]" id="rate" class="numeric add_to_total rate" onKeyPress="return disableEnterKey(event)"&gt;
&lt;?php
    //php code here for rates
?&gt;
&lt;/select&gt;
&lt;/td&gt;&lt;td&gt;&lt;input name="total[]" id="total" size="10" class="numeric is_total" 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>I use the following code to add up the total row, but it doesn't work for the second and subsequent dynamic rows.</p>

<pre><code>$(".add_to_total").change(function() {
    var total = 0;
    $(".add_to_total").each(function() {
        var quantity = parseFloat($(".quantity").val()) || 0;
        var part = parseFloat($(".part").val()) || 0;
        var hours = parseFloat($(".hours").val()) || 0;
        var rate = parseFloat($(".rate").val()) || 0;
        total = (Number(quantity) * Number(part)) + (Number(rate) * Number(hours));
    });
    $(".is_total").val(total);
});
</code></pre>

<p>I'm hoping someone can help me...I've tried everything I can think of, and I really want to get this thing solved, and move on with my life :)</p>

<p>Thanks in advance.</p>
