Moin!
var sumTotal = parseInt(0); // außerhalb einer jeden Funktion
function calcTotal (erg) {
sumTotal += eval(erg);
alert(sumTotal);
}Damit haut´s hin.
Naja, bis auf den total sinnlosen Einsatz von parseInt(0) bei der Initialisierung und den total sinnlosen Einsatz von eval() (da hätte, sofern nötig, parseInt(erg,10) hingehört) bei der Addition ist der Code tatsächlich marginal besser geworden ("+="-Operator genutzt).
Siehe http://de.selfhtml.org/javascript/objekte/unabhaengig.htm#parse_int, insbesondere das "Beachten Sie".
- Sven Rautenberg
--
"Love your nation - respect the others."
"Love your nation - respect the others."