Caclulating fields problem

Status
Not open for further replies.

cytino

New Member
Hi
I am trying to calculate the sum of 2 fields and show the rsults in a third:
I have used the following with onChange:

$('placedebt___total_debt').value = parseInt($('placedebt___debt_value').value) + parseInt($('placedebt___collection_value'));

I use this and keep getting a NAN result even when I enter any number in the first or second field?

Am I missing something

Please Help
 
OK, the problem with the javascript is because you have no default values for the two fields being used as the sum, but you have the script firing on both of them. So no matter which field you fill out first, the other is empty. So it tries to do the parseInt on an empty field, and empty is Not a Number (NaN).

I suspect if you set the two fields to default to 0 (zero), that error will probably go away.

I've responded to your PM.

-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top