You need to sign in to do that
Don't have an account?
jQuery Row Totals - Help with Row Id's
Hey all,
Hoping someone can help me with this simple issue.
I have the following jQuery which calculates the total for each row as the user inputs the data. I need to show the total to the user before they committ the data to the database.
<script> var j$ = jQuery.noConflict(); j$(document).ready(function(){ j$("[id$='qty'], [id$='cst']").blur(function(){ var unitCost = j$("[id$='cst']").val(); var quantity = j$("[id$='qty']").val(); var totCost = +unitCost + +quantity; j$("[id$='tol']").val(totCost); }); }); </script>
Unfortunatlely it only works on the first row. As far as I can tell the issue is around the jQuery not handling the row id's correct so it doesn't understand what it should be calculating. For example the first row has the id: j_id0:j_id5:j_id6:wtable:0:cst and the next row id is: j_id0:j_id5:j_id6:wtable:1:cst. So the number is increasing each time a row is being added.
So I need some help to add the number to the variables in the jQuery.
If anyone can help it would be really appreciated.
Thanks
Kev