Hi, I have the following code on my pages which is supposed to set focus to the login form when the user is not logged in:
When the user is not logged in, this is the only FORM which appears on the pages so accessing it through the forms[0] should be OK. The thing is that it works fine only sometimes. When I start the IE and it goes to my pages by default (I have set it as start page), I get an error which tells me that it's not possible to set focus to the element because it is either hidden or disabled. But the element is enabled and visible. Should I access the form and the element through names? If yes, what is the correct syntax for accessing the FORM named "login"? I presume that it is something like
but I'm not sure.
Any help will be appreciated.
Code:
onload="document.forms[0].elements[0].focus();"
When the user is not logged in, this is the only FORM which appears on the pages so accessing it through the forms[0] should be OK. The thing is that it works fine only sometimes. When I start the IE and it goes to my pages by default (I have set it as start page), I get an error which tells me that it's not possible to set focus to the element because it is either hidden or disabled. But the element is enabled and visible. Should I access the form and the element through names? If yes, what is the correct syntax for accessing the FORM named "login"? I presume that it is something like
Code:
forms['login'].elements['loginnameinput']
Any help will be appreciated.