This has nothing to do with Perl anymore. If document.getElementById('text') returns null, then there is no element with the id of 'text' in your HTML. If you're not already doing so, run Firefox and install the Firebug extension and spend some time getting to know it. I wouldn't think of doing any kind of Javascript or DOM debugging without it.