Avatar of n00b0101
n00b0101
 asked on

jquery: summing dynamic elements?

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>

Open in new window

jQuery

Avatar of undefined
Last Comment
amit_g

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
amit_g

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck