The problem is that you are adding by reading the input value for each key. If the user, for example, presses BACKSPACE to clear the input, the value will be an empty string, which will result in NaN after parseInt. And once you have NaN (in your variable total), you can no longer get rid of it.
Try the following:
document.getElementById('dds1').onkeyup = function() {
var value = parseInt(this.value, 10);
if ( !isNaN(value) ) {
total += value;
updateIt();
}
};
, . , .
:
document.getElementById('dds1').onkeyup = function() {
var value = parseInt(this.value, 10);
isNaN(value) && return;
total += value;
updateIt();
};
, , , .