Finally I found a simple solution for the FireFox error:
"[Exception... "'Permission denied to set property XULElement.selectedIndex' when calling method: [nsIAutoCompletePopup::selectedIndex]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)"
This error occurs when focus() is called. I was reported in https://bugzilla.mozilla.org/show_bug.cgi?id=236791 but still no fix/patch from mozilla.
To avoid this error, you have to turn off autocomplete.
from javascript, you can do that in following way: obj.setAttribute('autocomplete','off');
Or, you can simply set autocomplete="off" in HTML.
[http://geekswithblogs.net/shahedul/archive/2006/08/14/87910.aspx]