Link to home
Create AccountLog in
Avatar of 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);
                                var newInput=$("input",rowCopy).get(0);
// this is the accompanying html
<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>
// this is where I want to put the totals for drlabor[othours][], etc.
<td id="totalothours"></td>
<td id="totaldthours"></td>
<td id="totalbreak"></td>
<td id="totalshift"></td>

Open in new window

Avatar of amit_g
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account