The most likely reason is that you don't have an element with the id value "4". Consequently, document.getElementById returns null, and then when you try to look at the checked attribute, you're dereferencing a null, which throws an exception. Or of course, you don't have an element with the id value "TD4" and so your later getElementById returns null and you get the exception when assigning to innerHTML.
When trying to debug things, it's best to use a debugger. All modern browsers have debuggers built in — and some of them are quite good. On most browsers, pressing F12 will bring up the debugger, but if not go looking through the menus for "developer tools" or similar.
Even if there's no debugger, all browsers going back more than a decade have a means of telling you about JavaScript errors. I would at the very least enable that so you can see errors.
Side note: id values starting with digits are only recently allowed in HTML (valid in HTML5, not valid in HTML4 or earlier) and are still not valid in CSS. I recommend avoiding them.