The script sums 7 fields. To test I put an alert in it. When ran, I get 7 alert messages (normal). If I move the alert message down one bracket '}', out of the for loop, I get no alerts (not good). What's wrong with my logic? function mistot(){ var ep = document.forms[0].elements; var myamt = 'm-amt'; var mytot = 0; for(var i = 1; i <= 8; ++i) { if(isFloat(ep[myamt + i].value)){ mytot += +ep[myamt + i].value; } alert('test') } }
This is a JavaScript issue not ASP. But the problem I would guess is with: mytot += +ep[myamt + i].value; You have a '+' before ep. It may also be that the index 'myamt + i' is out of range or that the object does not support 'value'.
The line "mytot += +ep[myamt + i].value; " should be 'mytot += ep[myamt + i].value; ". There is an extra '+' symbol