Ugly ugly ugly.
WHY would you use document.write() to create all that?
Anyway, it's obvious why it won't work: You are creating the calculator, including
<form name="Keypad">, in a SEPARATE WINDOW!
document.Keypad *DOES NOT EXIST* in the current wndow!
Pardon me, but this entire effor is just very very wrong headed.
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.