troubleshooting Question

jquery: summing dynamic elements?

Avatar of n00b0101
n00b0101 asked on
jQuery
1 Comment1 Solution373 ViewsLast Modified:
I have a form, where, once you begin to add text, another row beneath it will appear.  (The code for that is below).  I'm trying to figure out how to sum these values on input as they're added?  
// this is the jquery that appends a row
$( function(){
        $("#dnotes > tbody > tr > td > input").bind('focus', function(){
                        var row = $(this).closest("tr").get(0);
                        if( row.className.indexOf("clicked")==-1 )
                        {       
                                var rowCopy=$(row).clone(true);
                                $(row).closest("tbody").append(rowCopy);
                                row.className+="clicked";
                                var newInput=$("input",rowCopy).get(0);
                                newInput.id="newId";
                                $(newInput).bind('focus',attachAutoCompleteEEValues);
                        }
        });
});
 
// this is the accompanying html
<tr>
<td><input type="text" id="diningroomemployee" name="drlabor[employee][]" /></td>
<td><input type="text" name="drlabor[othours][]" value=""  /></td>
<td><input type="text" name="drlabor[dthours][]" value=""  /></td>
<td><input type="text" name="drlabor[break][]" value="" /></td>
<td><input type="text" name="drlabor[shift][]" value="" class="standardTextfieldSmall" /></td>
</tr>
 
// this is where I want to put the totals for drlabor[othours][], etc.
<tr>
<td id="totalothours"></td>
<td id="totaldthours"></td>
<td id="totalbreak"></td>
<td id="totalshift"></td>
</tr>
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros