[thelist] js problem

Tom Dell'Aringa pixelmech at yahoo.com
Fri Sep 13 16:15:10 CDT 2002


--- ".jeff" <jeff at members.evolt.org> wrote:

> why not ditch the global variable and call your defaultFocus()
> function, passing the field you want to focus?
>
> function defaultFocus(oElement)
> {
>   oElement.focus();
> }
>
> and call it like this:
>
> defaultFocus(document.forms[0].elements['lastname']);

This throws an error in IE6 "document.forms.0.elements is null or not
an object". I tried naming my form and using that name in the form
array, which didn't work either. I made sure my element had
name="lastname" in it as well, it also has the same id.

My text input IS nested in a label tag..I thought that was it but
removing that didn't help...

> fwiw, i noticed an issue that you may wish to address in your
> coding style -- the reliance on the getElementById() method.
> there's really no reason to address form elements by id.  you're
> unnecessarily breaking form functionality (and introducing errors
> as far as i can tell) for older browsers.  use the elements array
> and the name value.  it's always worked for script enabled browsers
> and probably always will (i don't ever see the spec changing to
> deprecate the name attribute of form fields).
>
> .jeff

That sounds right to me..and yet..the error...

=====
var me = tom.pixelmech.webDeveloper();

http://www.pixelmech.com/
http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]

__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com



More information about the thelist mailing list