ID returns null

Why does firebug tell me that key_field is undefined? Is it because I haven’t defined it in the HTML?

key_input.setAttribute(‘id’, ‘companykey’);
var key_field = document.getElementById(‘companykey’);

As long as key_input is a DOM element, that code should work fine. Can you provide a little bit more?

I got it working. Thanks.