Prefer to use Number() rather than parseInt() - parseInt() is intended for conversion of numbers from one base to another. If you
do use parseInt() you ought to specify the radix (10).
You ask the user to enter
numbers, but then change them to
integers. Why can the user not enter 2.5, 3.7 and so on? And what if the user enters "XYZ" or something? You can trap NaN entries with
Code:
var box1 = Number(document.calculator.txtBox1.value) || 0; // assign 0 if the value entered is not a number.
box1 = parseInt(box1,10); // if you really do want integers. 10 is the radix (number base - i.e. decimal)
document.calculator.txtBox1.value = box1; // write it back to the field
Not sure what your document.write() is intended to output, but simply scrap it.