I'm trying to do some simple calculations with javascript. but for some reason instead of calculating the values of the variables, it would just append the values together like a string.
for example:
if i'm trying to get something like this:
5 + 4 = 9;
i end up with something like this:
5 + 4 = 54;
as far as I can tell i'm declaring the variables right. i'm printing out two separate calculations, 'refund_amount' and 'air_total'. the first one (refund_amount) is calculating fine, but the latter is acting like a string and appending the values together.
here is the full function:
for example:
if i'm trying to get something like this:
5 + 4 = 9;
i end up with something like this:
5 + 4 = 54;
as far as I can tell i'm declaring the variables right. i'm printing out two separate calculations, 'refund_amount' and 'air_total'. the first one (refund_amount) is calculating fine, but the latter is acting like a string and appending the values together.
here is the full function:
| Code: |
| // JavaScript Document
//calculation to be done on the form function calc () { var refund_amount; var air_total; refund_amount = document.getElementById('origPrice').value; if (document.form.refundIns[0].checked==true) { refund_amount = refund_amount - document.getElementById('lessIns').value; } if (document.form.destSrv[0].checked==true) { refund_amount = refund_amount - document.getElementById('destService').value; } air_total = document.getElementById('penaltiesAirSupplier').value + document.getElementById('penaltiesAirPanda').value; document.getElementById('refundAmt').innerHTML = refund_amount; document.getElementById('airTotal').innerHTML = air_total; }//end calc () function |
