jquery total not grabbing them all

I had some great help yesterday with jquery - updating a top grid and changing the values that match in the lower grid.  Client asked for a total to change as the fields change but what i have done, it is only totally the fields that changed, not all of them.

 $(document).ready(function () {
    $('input','#masterGridTable').change(function() {
		var txtAmtval = $(this).val();
        var txtClassId = "." + $(this).attr("id");
  		//change txtInterest% value

    $("input[id^='NewDues']").change(function() {
        var currentId = $(this).attr("id").replace("NewDues","");
        var oldId = "#OldDues" + currentId;
        var changeId = "#PChange" + currentId;
       	var txtNewDues = parseFloat($(this).val());
	   	var txtOldDuesDues = parseFloat($(oldId).val());
  		//change txtInterest% value
		if (txtOldDuesDues > 0) {
  		$(changeId).val((((txtNewDues - txtOldDuesDues) / txtOldDuesDues) * 100).toFixed(2));
	function calculateTotal() {
        var sum = 0;
        $("input[id^='NewDues']").each(function() {
            if(!isNaN(this.value) && this.value.length!=0) {
                sum += parseFloat(this.value);


Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rainer JeschorCommented:
this is due to the "$" and "," in the existing - non updated values - because they will fail the isNaN check

Quick and dirty:
var currentValue = $(this).val().replace("$","").replace(",","");
        if(!isNaN(currentValue) && currentValue.length!=0) {
                sum += parseFloat(currentValue);

Open in new window

There might be better solutions using regEx but there are also some really helpful JavaScript libraries which can help in converting the dollar amount into a numeric value like numeral.js:

Live sample:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.