function updateTotal() { var s = document.getElementById('single'); var total = 0; if (!isNaN(parseInt(s.value)) && parseInt(s.value) > 0) { num = parseInt(s.value); if (num < 10) total += num * 59; else if (num < 25) total += num * 50; else if (num < 50) total += num * 45; else total += num * 40; } document.getElementById('total').innerHTML = total; document.getElementById('ftotal').value = total; }