I was using document.getElementById('...') as you've said, however I just tested without document. and the same problem arises. First one produces an error, second+ work fine.
Yes, all IDs are from an identity column in my table. Completely unique.
As a footnote, the two examples I provided...