C
charliefortune
Every time a field in an accounts form changes, an onChange =
"updateAmount()" executes this function -
function updateAmount(x){
var field = 'amount' + x;
var val = parseFloat(document.forms[0].field.value);
document.forms[0].totAmount.value = val;
}
the fields are called 'amount1', 'amount2', 'amount3' etc. and the
onChange passes that integer. I want to calculate a new total every
time a new amount is entered.
1. Is there a way to avoid having to pass the 'x' index. Surely the DOM
knows which field is provoking the function call.
2. The parseFloat doesn't seem to work, is my syntax correct ?
Thank you
"updateAmount()" executes this function -
function updateAmount(x){
var field = 'amount' + x;
var val = parseFloat(document.forms[0].field.value);
document.forms[0].totAmount.value = val;
}
the fields are called 'amount1', 'amount2', 'amount3' etc. and the
onChange passes that integer. I want to calculate a new total every
time a new amount is entered.
1. Is there a way to avoid having to pass the 'x' index. Surely the DOM
knows which field is provoking the function call.
2. The parseFloat doesn't seem to work, is my syntax correct ?
Thank you